Skip to content

Rollup of 7 pull requests #139194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ impl<'tcx> rustc_type_ir::Flags for Clauses<'tcx> {
/// environment. `ParamEnv` is the type that represents this information. See the
/// [dev guide chapter][param_env_guide] for more information.
///
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/param_env/param_env_summary.html
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(HashStable, TypeVisitable, TypeFoldable)]
pub struct ParamEnv<'tcx> {
Expand All @@ -977,7 +977,7 @@ impl<'tcx> ParamEnv<'tcx> {
/// to use an empty environment. See the [dev guide section][param_env_guide]
/// for information on what a `ParamEnv` is and how to acquire one.
///
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/param_env/param_env_summary.html
/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
#[inline]
pub fn empty() -> Self {
Self::new(ListWithCachedTypeInfo::empty())
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use rustc_session::lint::builtin::{
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_ATTRIBUTES,
};
use rustc_session::parse::feature_err;
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, edition, kw, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
use rustc_trait_selection::traits::ObligationCtxt;
Expand Down Expand Up @@ -1038,14 +1038,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we
// can remove the `SelfTy` case here, remove `sym::SelfTy`, and update the
// `#[doc(keyword = "SelfTy")` attribute in `library/std/src/keyword_docs.rs`.
s <= kw::Union || s == sym::SelfTy
s.is_reserved(|| edition::LATEST_STABLE_EDITION) || s.is_weak() || s == sym::SelfTy
}

let doc_keyword = meta.value_str().unwrap_or(kw::Empty);
if doc_keyword == kw::Empty {
self.doc_attr_str_error(meta, "keyword");
return;
}
let doc_keyword = match meta.value_str() {
Some(value) if value != kw::Empty => value,
_ => return self.doc_attr_str_error(meta, "keyword"),
};

let item_kind = match self.tcx.hir_node(hir_id) {
hir::Node::Item(item) => Some(&item.kind),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
));
}
Scope::BuiltinAttrs => {
let res = Res::NonMacroAttr(NonMacroAttrKind::Builtin(kw::Empty));
let res = Res::NonMacroAttr(NonMacroAttrKind::Builtin(sym::dummy));
if filter_fn(res) {
suggestions.extend(
BUILTIN_ATTRIBUTES
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_span/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,8 @@ pub fn decode_syntax_context<D: Decoder, F: FnOnce(&mut D, u32) -> SyntaxContext
}
}
Entry::Vacant(entry) => {
// We are the first thread to start decoding. Mark the current thread as being progress.
// We are the first thread to start decoding. Mark the current thread as being
// progress.
context.local_in_progress.borrow_mut().insert(raw_id);

// Allocate and store SyntaxContext id *before* calling the decoder function,
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ symbols! {
// tidy-alphabetical-end

// Weak keywords, have special meaning only in specific contexts.
// Matching predicates: none
// Matching predicates: `is_weak`
// tidy-alphabetical-start
Auto: "auto",
Builtin: "builtin",
Expand Down Expand Up @@ -2725,6 +2725,10 @@ impl Symbol {
|| self.is_unused_keyword_conditional(edition)
}

pub fn is_weak(self) -> bool {
self >= kw::Auto && self <= kw::Yeet
}

/// A keyword or reserved identifier that can be used as a path segment.
pub fn is_path_segment_keyword(self) -> bool {
self == kw::Super
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target {
);

Target {
llvm_target: "thumbv7a-vita-eabihf".into(),
llvm_target: "thumbv7a-sony-vita-eabihf".into(),
metadata: TargetMetadata {
description: Some(
"Armv7-A Cortex-A9 Sony PlayStation Vita (requires VITASDK toolchain)".into(),
Expand Down
26 changes: 0 additions & 26 deletions src/doc/unstable-book/src/library-features/c-variadic.md

This file was deleted.

30 changes: 16 additions & 14 deletions src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
if apa.counter <= 1 || !apa.has_expensive_expr_after_last_attr {
continue;
}
let first_bind_ident = apa.first_bind_ident.unwrap();
span_lint_and_then(
cx,
SIGNIFICANT_DROP_TIGHTENING,
apa.first_bind_ident.span,
first_bind_ident.span,
"temporary with significant `Drop` can be early dropped",
|diag| {
match apa.counter {
Expand All @@ -91,13 +92,13 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
let indent = " ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0));
let init_method = snippet(cx, apa.first_method_span, "..");
let usage_method = snippet(cx, apa.last_method_span, "..");
let stmt = if apa.last_bind_ident == Ident::empty() {
format!("\n{indent}{init_method}.{usage_method};")
} else {
let stmt = if let Some(last_bind_ident) = apa.last_bind_ident {
format!(
"\n{indent}let {} = {init_method}.{usage_method};",
snippet(cx, apa.last_bind_ident.span, ".."),
snippet(cx, last_bind_ident.span, ".."),
)
} else {
format!("\n{indent}{init_method}.{usage_method};")
};

diag.multipart_suggestion_verbose(
Expand All @@ -113,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
format!(
"\n{}drop({});",
" ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0)),
apa.first_bind_ident
first_bind_ident
),
Applicability::MaybeIncorrect,
);
Expand All @@ -124,7 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
apa.first_block_span,
format!(
"temporary `{}` is currently being dropped at the end of its contained scope",
apa.first_bind_ident
first_bind_ident
),
);
},
Expand Down Expand Up @@ -283,7 +284,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
let mut apa = AuxParamsAttr {
first_block_hir_id: self.ap.curr_block_hir_id,
first_block_span: self.ap.curr_block_span,
first_bind_ident: ident,
first_bind_ident: Some(ident),
first_method_span: {
let expr_or_init = expr_or_init(self.cx, expr);
if let hir::ExprKind::MethodCall(_, local_expr, _, span) = expr_or_init.kind {
Expand All @@ -307,7 +308,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
match self.ap.curr_stmt.kind {
hir::StmtKind::Let(local) => {
if let hir::PatKind::Binding(_, _, ident, _) = local.pat.kind {
apa.last_bind_ident = ident;
apa.last_bind_ident = Some(ident);
}
if let Some(local_init) = local.init
&& let hir::ExprKind::MethodCall(_, _, _, span) = local_init.kind
Expand Down Expand Up @@ -373,15 +374,15 @@ struct AuxParamsAttr {
first_block_span: Span,
/// The binding or variable that references the initial construction of the type marked with
/// `#[has_significant_drop]`.
first_bind_ident: Ident,
first_bind_ident: Option<Ident>,
/// Similar to `init_bind_ident` but encompasses the right-hand method call.
first_method_span: Span,
/// Similar to `init_bind_ident` but encompasses the whole contained statement.
first_stmt_span: Span,

/// The last visited binding or variable span within a block that had any referenced inner type
/// marked with `#[has_significant_drop]`.
last_bind_ident: Ident,
last_bind_ident: Option<Ident>,
/// Similar to `last_bind_span` but encompasses the right-hand method call.
last_method_span: Span,
/// Similar to `last_bind_span` but encompasses the whole contained statement.
Expand All @@ -395,10 +396,10 @@ impl Default for AuxParamsAttr {
has_expensive_expr_after_last_attr: false,
first_block_hir_id: HirId::INVALID,
first_block_span: DUMMY_SP,
first_bind_ident: Ident::empty(),
first_bind_ident: None,
first_method_span: DUMMY_SP,
first_stmt_span: DUMMY_SP,
last_bind_ident: Ident::empty(),
last_bind_ident: None,
last_method_span: DUMMY_SP,
last_stmt_span: DUMMY_SP,
}
Expand All @@ -413,7 +414,7 @@ fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
}
}

fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_>) -> bool {
fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Option<Ident>, lcx: &LateContext<'_>) -> bool {
if let hir::ExprKind::Call(fun, [first_arg]) = expr.kind
&& let hir::ExprKind::Path(hir::QPath::Resolved(_, fun_path)) = &fun.kind
&& let Res::Def(DefKind::Fn, did) = fun_path.res
Expand All @@ -422,6 +423,7 @@ fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_
let has_ident = |local_expr: &hir::Expr<'_>| {
if let hir::ExprKind::Path(hir::QPath::Resolved(_, arg_path)) = &local_expr.kind
&& let [first_arg_ps, ..] = arg_path.segments
&& let Some(first_bind_ident) = first_bind_ident
&& &first_arg_ps.ident == first_bind_ident
{
true
Expand Down
29 changes: 21 additions & 8 deletions src/tools/tidy/src/unstable_book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ fn collect_unstable_book_lib_features_section_file_names(base_src_path: &Path) -
collect_unstable_book_section_file_names(&unstable_book_lib_features_path(base_src_path))
}

/// Would switching underscores for dashes work?
fn maybe_suggest_dashes(names: &BTreeSet<String>, feature_name: &str, bad: &mut bool) {
let with_dashes = feature_name.replace('_', "-");
if names.contains(&with_dashes) {
tidy_error!(
bad,
"the file `{}.md` contains underscores; use dashes instead: `{}.md`",
feature_name,
with_dashes,
);
}
}

pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
let lang_features = features.lang;
let lib_features = features
Expand All @@ -93,14 +106,13 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
// Check for Unstable Book sections that don't have a corresponding unstable feature
for feature_name in &unstable_book_lib_features_section_file_names - &unstable_lib_feature_names
{
if !unstable_lang_feature_names.contains(&feature_name) {
tidy_error!(
bad,
"The Unstable Book has a 'library feature' section '{}' which doesn't \
tidy_error!(
bad,
"The Unstable Book has a 'library feature' section '{}' which doesn't \
correspond to an unstable library feature",
feature_name
);
}
feature_name
);
maybe_suggest_dashes(&unstable_lib_feature_names, &feature_name, bad);
}

// Check for Unstable Book sections that don't have a corresponding unstable feature.
Expand All @@ -112,7 +124,8 @@ pub fn check(path: &Path, features: CollectedFeatures, bad: &mut bool) {
"The Unstable Book has a 'language feature' section '{}' which doesn't \
correspond to an unstable language feature",
feature_name
)
);
maybe_suggest_dashes(&unstable_lang_feature_names, &feature_name, bad);
}

// List unstable features that don't have Unstable Book sections.
Expand Down
23 changes: 0 additions & 23 deletions tests/ui/codegen/equal-pointers-unequal/as-cast/print3.rs

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions tests/ui/resolve/auxiliary/macro_helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* macro namespace. */

extern crate proc_macro;
use proc_macro::*;
use std::str::FromStr;

const ERROR: &str = "fn helper() { \"helper\" }";
// https://doc.rust-lang.org/nightly/std/prelude/v1/index.html#attributes
// NOTE: all the bang macros in std are currently unstable.
#[proc_macro_attribute] pub fn test // lang.
(_: TokenStream, _: TokenStream) -> TokenStream {
TokenStream::from_str("fn test_macro() { \"\" }").unwrap() }
// https://doc.rust-lang.org/nightly/reference/attributes.html#built-in-attributes-index
#[proc_macro_attribute] pub fn global_allocator // lang.
(_: TokenStream, _: TokenStream) -> TokenStream {
TokenStream::from_str("fn global_allocator_macro() { \"\" }").unwrap() }
Loading
Loading