diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index 4a8dabbf724df..4e68f72d08051 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -14,7 +14,8 @@ use crate::{ // Explicitly import `Float` to avoid ambiguity with `Primitive::Float`. #[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct Layout<'a>(pub Interned<'a, LayoutData>); impl<'a> fmt::Debug for Layout<'a> { diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index b6944a72c0f89..e93be27de7fb3 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1,7 +1,9 @@ // tidy-alphabetical-start #![cfg_attr(feature = "nightly", allow(internal_features))] +#![cfg_attr(feature = "nightly", feature(register_tool))] #![cfg_attr(feature = "nightly", feature(rustc_attrs))] #![cfg_attr(feature = "nightly", feature(step_trait))] +#![cfg_attr(feature = "nightly", register_tool(lint))] // tidy-alphabetical-end /*! ABI handling for rustc diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index 46d8e11cc0931..c6e5940938579 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -10,7 +10,9 @@ #![feature(deref_patterns)] #![feature(iter_order_by)] #![feature(macro_metavar_expr)] +#![feature(register_tool)] #![recursion_limit = "256"] +#![register_tool(lint)] // tidy-alphabetical-end pub mod util { diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 202b130cd9a36..563d8e09bd674 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -780,4 +780,20 @@ fn check_features_requiring_new_solver(sess: &Session, features: &Features) { missing: String::from("-Znext-solver=globally"), }); } + + // Require the new solver with unsafe binders. It's just too much work to + // support both solvers. + if let Some(unsafe_binders_span) = features + .enabled_lang_features() + .iter() + .find(|feat| feat.gate_name == sym::unsafe_binders) + .map(|feat| feat.attr_sp) + { + #[allow(rustc::symbol_intern_string_literal)] + sess.dcx().emit_err(diagnostics::MissingDependentFeatures { + parent_span: unsafe_binders_span, + parent: sym::unsafe_binders, + missing: String::from("-Znext-solver=globally"), + }); + } } diff --git a/compiler/rustc_attr_ir/src/data_structures.rs b/compiler/rustc_attr_ir/src/data_structures.rs index 26db9819bb7ca..1edc6d4726408 100644 --- a/compiler/rustc_attr_ir/src/data_structures.rs +++ b/compiler/rustc_attr_ir/src/data_structures.rs @@ -991,9 +991,22 @@ pub enum AttributeKind { /// Represents `#[allow]`, `#[warn]`, `#[deny]`, `#[forbid]`, and `#[expect]`. LintCheck(ThinVec), + /// Represents `#[lint::must_match_exhaustively]` (used by the + /// `rustc::must_match_exhaustively` lint). + LintMustMatchExhaustively(Span), + /// Represents `#[lint::never_returns_null_ptr]` (used by the `useless_ptr_null_checks` lint). LintNeverReturnsNullPtr, + /// Represents `#[lint::no_implicit_autorefs]` (used by the `dangerous_implicit_autorefs` lint). + LintNoImplicitAutorefs, + + /// Represents `#[lint::panics_when_zero]` (used by the `unconditional_panic` lint). + LintPanicsWhenZero, + + /// Represents `#[lint::pass_by_value)]` (used by the `rustc::disallowed_pass_by_ref` lint). + LintPassByValue, + /// Represents `#[lint::should_not_be_called_on_const_items]` (used by the /// `const_item_interior_mutations` lint). LintShouldNotBeCalledOnConstItems, @@ -1421,13 +1434,6 @@ pub enum AttributeKind { attr_span: Span, fn_names: ThinVec, }, - - /// Represents `#[rustc_must_match_exhaustively]` - RustcMustMatchExhaustively(Span), - - /// Represents `#[rustc_no_implicit_autorefs]` - RustcNoImplicitAutorefs, - /// Represents `#[rustc_no_implicit_bounds]` RustcNoImplicitBounds, @@ -1459,18 +1465,13 @@ pub enum AttributeKind { /// Represents `#[rustc_offload_kernel]` RustcOffloadKernel, - /// Represents `#[rustc_panics_when_zero]` (used for linting). - RustcPanicsWhenZero, - /// Represents `#[rustc_paren_sugar]`. RustcParenSugar, - /// Represents `#[rustc_pass_by_value]` (used by the `rustc_pass_by_value` lint). - RustcPassByValue, - /// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`, /// /// See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details. + /// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]` RustcPassIndirectlyInNonRusticAbis(Span), /// Represents `#[rustc_preserve_ub_checks]` diff --git a/compiler/rustc_attr_ir/src/encode_cross_crate.rs b/compiler/rustc_attr_ir/src/encode_cross_crate.rs index ca9b79ccc8a51..b0e067a656502 100644 --- a/compiler/rustc_attr_ir/src/encode_cross_crate.rs +++ b/compiler/rustc_attr_ir/src/encode_cross_crate.rs @@ -60,7 +60,11 @@ impl AttributeKind { Linkage(..) => No, LintAsPtr => Yes, LintCheck(..) => No, + LintMustMatchExhaustively(..) => Yes, LintNeverReturnsNullPtr => Yes, + LintNoImplicitAutorefs => Yes, + LintPanicsWhenZero => Yes, + LintPassByValue => Yes, LintShouldNotBeCalledOnConstItems => Yes, LoopMatch(..) => No, MacroEscape => No, @@ -168,8 +172,6 @@ impl AttributeKind { RustcMain => No, RustcMir(..) => Yes, RustcMustImplementOneOf { .. } => No, - RustcMustMatchExhaustively(..) => Yes, - RustcNoImplicitAutorefs => Yes, RustcNoImplicitBounds => No, RustcNoMirInline => Yes, RustcNoWritable => Yes, @@ -179,9 +181,7 @@ impl AttributeKind { RustcObjcClass { .. } => No, RustcObjcSelector { .. } => No, RustcOffloadKernel => Yes, - RustcPanicsWhenZero => Yes, RustcParenSugar => No, - RustcPassByValue => Yes, RustcPassIndirectlyInNonRusticAbis(..) => No, RustcPreserveUbChecks => No, RustcProcMacroDecls => No, @@ -279,7 +279,11 @@ impl AttributeKind { }, LintAsPtr => false, LintCheck(_) => false, + LintMustMatchExhaustively(..) => false, LintNeverReturnsNullPtr => false, + LintNoImplicitAutorefs => false, + LintPanicsWhenZero => false, + LintPassByValue => false, LintShouldNotBeCalledOnConstItems => false, LoopMatch(..) => false, MacroEscape => false, @@ -387,8 +391,6 @@ impl AttributeKind { RustcMain => false, RustcMir(..) => false, RustcMustImplementOneOf { .. } => false, - RustcMustMatchExhaustively(..) => false, - RustcNoImplicitAutorefs => false, RustcNoImplicitBounds => false, RustcNoMirInline => false, RustcNoWritable => false, @@ -398,9 +400,7 @@ impl AttributeKind { RustcObjcClass { .. } => false, RustcObjcSelector { .. } => false, RustcOffloadKernel => true, - RustcPanicsWhenZero => false, RustcParenSugar => false, - RustcPassByValue => false, RustcPassIndirectlyInNonRusticAbis(..) => false, RustcPreserveUbChecks => false, RustcProcMacroDecls => false, diff --git a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs index 4b457e09c9cff..d4938e18e3753 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs @@ -57,16 +57,16 @@ impl NoArgsAttributeParser for RustcPubTransparentParser { } } -pub(crate) struct RustcPassByValueParser; -impl NoArgsAttributeParser for RustcPassByValueParser { - const PATH: &[Symbol] = &[sym::rustc_pass_by_value]; +pub(crate) struct LintPassByValueParser; +impl NoArgsAttributeParser for LintPassByValueParser { + const PATH: &[Symbol] = &[sym::lint, sym::pass_by_value]; const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ Allow(Target::Struct), Allow(Target::Enum), Allow(Target::TyAlias), ]); const STABILITY: AttributeStability = unstable!(rustc_attrs); - const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPassByValue; + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::LintPassByValue; } pub(crate) struct LintShouldNotBeCalledOnConstItemsParser; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 629a4ba305584..b2c5b6f030f24 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -89,21 +89,21 @@ impl SingleAttributeParser for RustcMustImplementOneOfParser { } } -pub(crate) struct RustcPanicsWhenZeroParser; +pub(crate) struct LintPanicsWhenZeroParser; -impl NoArgsAttributeParser for RustcPanicsWhenZeroParser { - const PATH: &[Symbol] = &[sym::rustc_panics_when_zero]; +impl NoArgsAttributeParser for LintPanicsWhenZeroParser { + const PATH: &[Symbol] = &[sym::lint, sym::panics_when_zero]; const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::ConstParam)]); const STABILITY: AttributeStability = unstable!(rustc_attrs); - const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPanicsWhenZero; + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::LintPanicsWhenZero; } -pub(crate) struct RustcNoImplicitAutorefsParser; +pub(crate) struct LintNoImplicitAutorefsParser; -impl NoArgsAttributeParser for RustcNoImplicitAutorefsParser { - const PATH: &[Symbol] = &[sym::rustc_no_implicit_autorefs]; +impl NoArgsAttributeParser for LintNoImplicitAutorefsParser { + const PATH: &[Symbol] = &[sym::lint, sym::no_implicit_autorefs]; const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ Allow(Target::Fn), Allow(Target::Method(MethodKind::Inherent)), @@ -113,7 +113,7 @@ impl NoArgsAttributeParser for RustcNoImplicitAutorefsParser { ]); const STABILITY: AttributeStability = unstable!(rustc_attrs); - const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitAutorefs; + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::LintNoImplicitAutorefs; } pub(crate) struct RustcLegacyConstGenericsParser; @@ -1149,10 +1149,10 @@ impl NoArgsAttributeParser for RustcIntrinsicConstStableIndirectParser { pub(crate) struct RustcExhaustiveParser; impl NoArgsAttributeParser for RustcExhaustiveParser { - const PATH: &'static [Symbol] = &[sym::rustc_must_match_exhaustively]; + const PATH: &'static [Symbol] = &[sym::lint, sym::must_match_exhaustively]; const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Enum)]); const STABILITY: AttributeStability = unstable!(rustc_attrs); - const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcMustMatchExhaustively; + const CREATE: fn(Span) -> AttributeKind = AttributeKind::LintMustMatchExhaustively; } pub(crate) struct RustcCanonicalSymbolParser; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 59c583d4eb435..3a51c78f687e7 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -277,6 +277,9 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, + Single>, + Single>, Single>, Single>, Single>, @@ -337,7 +340,6 @@ attribute_parsers!( Single>, Single>, Single>, - Single>, Single>, Single>, Single>, @@ -345,9 +347,7 @@ attribute_parsers!( Single>, Single>, Single>, - Single>, Single>, - Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index 4274c21ffd26f..73229499e077c 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -145,9 +145,7 @@ impl<'sess> AttributeParser<'sess> { /// This can be used for attributes that would be removed before `rustc_ast_lowering`, such as attributes on macro calls. /// /// Try to use this as little as possible. Attributes *should* be lowered during - /// `rustc_ast_lowering`. Some attributes require access to features to parse, which would - /// crash if you tried to do so through [`parse_limited_all`](Self::parse_limited_all). - /// Therefore, if `parse_filter` is None, then features *must* be provided. + /// `rustc_ast_lowering`. pub fn parse_limited_all( sess: &'sess Session, attrs: &[ast::Attribute], @@ -159,6 +157,10 @@ impl<'sess> AttributeParser<'sess> { should_emit: ShouldEmit, attr_tools: Option<&'sess RegisteredTools>, ) -> Vec { + // Some attributes require access to features to parse. + // Therefore, if `parse_filter` is None, then features *must* be provided. + assert!(parse_filter.is_some() || features.is_some()); + let mut p = AttributeParser { features, attr_tools, parse_filter, sess, should_emit }; p.parse_attribute_list( attrs, diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index cdfa160120d8e..a3a27d0eb1f33 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -7,9 +7,11 @@ #![feature(file_buffered)] #![feature(negative_impls)] #![feature(option_into_flat_iter)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![feature(stmt_expr_attributes)] #![feature(try_blocks)] +#![register_tool(lint)] // tidy-alphabetical-end use std::borrow::Cow; diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 9d24f1687f2b0..019567e834776 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -12,8 +12,10 @@ #![feature(iter_intersperse)] #![feature(macro_derive)] #![feature(once_cell_try)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![feature(try_blocks)] +#![register_tool(lint)] // tidy-alphabetical-end pub use crate::back::llvm_backend::{LlvmCodegenBackend, ModuleLlvm}; diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi/branded.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi/branded.rs index 08ebdcc70871a..ef80b0b766b76 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi/branded.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi/branded.rs @@ -9,7 +9,8 @@ type PhantomInvariantLifetime<'a> = PhantomData &'a ()>; /// Corresponds to `LLVMContextRef`. #[derive(Clone, Copy)] #[repr(transparent)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub(crate) struct Context<'ll> { llcx_raw: ptr::NonNull, _invariant_ll: PhantomInvariantLifetime<'ll>, @@ -18,7 +19,8 @@ pub(crate) struct Context<'ll> { /// Corresponds to `LLVMModuleRef`. #[derive(Clone, Copy)] #[repr(transparent)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub(crate) struct Module<'ll> { llmod_raw: ptr::NonNull, _invariant_ll: PhantomInvariantLifetime<'ll>, @@ -65,7 +67,8 @@ pub(crate) unsafe fn wrap_llmod<'ll>( /// can be compared for equality (and hashed) based on their pointer address. #[derive(Clone, Copy, PartialEq, Eq, Hash)] #[repr(transparent)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub(crate) struct Type<'ll> { llty_raw: ptr::NonNull, _invariant_ll: PhantomInvariantLifetime<'ll>, @@ -79,7 +82,8 @@ unsafe extern "C" { /// Corresponds to `LLVMValueRef`. #[derive(Clone, Copy, PartialEq, Eq, Hash)] #[repr(transparent)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub(crate) struct Value<'ll> { llval_raw: ptr::NonNull, _invariant_ll: PhantomInvariantLifetime<'ll>, @@ -93,7 +97,8 @@ unsafe extern "C" { /// Corresponds to `LLVMAttributeRef`. #[derive(Clone, Copy)] #[repr(transparent)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub(crate) struct Attribute<'ll> { llattr_raw: ptr::NonNull, _invariant_ll: PhantomInvariantLifetime<'ll>, diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 382c921f198e0..9be81f1cd74a4 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -32,7 +32,8 @@ mod private { /// The `PrivateZst` field means you can pattern match with `Interned(v, _)` but you can only /// construct a `Interned` with `new_unchecked`, and not directly. This means that all creation /// points can be audited easily. -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct Interned<'a, T>(pub &'a T, pub private::PrivateZst); impl<'a, T> Interned<'a, T> { diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 747e36f382a4e..56d23d9ccec41 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -28,12 +28,14 @@ #![feature(negative_impls)] #![feature(nonzero_internals)] #![feature(pattern_types)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![feature(sized_hierarchy)] #![feature(thread_id_value)] #![feature(trait_alias)] #![feature(trusted_len)] #![feature(type_alias_impl_trait)] +#![register_tool(lint)] // tidy-alphabetical-end // This allows derive macros to reference this crate diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index fb6e1d43a4375..2dbfc65325b22 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -6,6 +6,8 @@ #![feature(default_field_values)] #![feature(macro_metavar_expr_concat)] #![feature(negative_impls)] +#![feature(register_tool)] +#![register_tool(lint)] // tidy-alphabetical-end extern crate self as rustc_errors; diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index c431e4aa2ba9b..0b62f86c7c692 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -229,8 +229,6 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[ sym::rustc_main, sym::rustc_mir, sym::rustc_must_implement_one_of, - sym::rustc_must_match_exhaustively, - sym::rustc_no_implicit_autorefs, sym::rustc_no_implicit_bounds, sym::rustc_no_mir_inline, sym::rustc_no_writable, @@ -241,11 +239,9 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[ sym::rustc_objc_selector, sym::rustc_offload_kernel, sym::rustc_on_unimplemented, - sym::rustc_panics_when_zero, sym::rustc_paren_sugar, sym::rustc_partition_codegened, sym::rustc_partition_reused, - sym::rustc_pass_by_value, sym::rustc_pass_indirectly_in_non_rustic_abis, sym::rustc_preserve_ub_checks, sym::rustc_proc_macro_decls, diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 369511aa9c671..1ae32bfd11382 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -59,8 +59,10 @@ This API is completely unstable and subject to change. #![feature(default_field_values)] #![feature(gen_blocks)] #![feature(iter_intersperse)] +#![feature(register_tool)] #![feature(slice_partition_dedup)] #![feature(try_blocks)] +#![register_tool(lint)] // tidy-alphabetical-end // These are used by Clippy. diff --git a/compiler/rustc_hir_id/src/lib.rs b/compiler/rustc_hir_id/src/lib.rs index 7cb43e9a8ccf9..d6fe9e12bfa33 100644 --- a/compiler/rustc_hir_id/src/lib.rs +++ b/compiler/rustc_hir_id/src/lib.rs @@ -1,8 +1,13 @@ //! Library containing Id types from `rustc_hir`, split out so crates can use it without depending //! on all of `rustc_hir` (which is large and depends on other large things like `rustc_target`). + +// tidy-alphabetical-start #![allow(internal_features)] #![feature(negative_impls)] +#![feature(register_tool)] #![feature(rustc_attrs)] +#![register_tool(lint)] +// tidy-alphabetical-end pub mod def_path_hash_map; pub mod definitions; @@ -95,7 +100,8 @@ impl ToStableHashKey for OwnerId { /// incremental compilation where we have to persist things through changes to /// the code base. #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct HirId { pub owner: OwnerId, pub local_id: ItemLocalId, diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 618052418c3f9..a2d066131d2c3 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -4,6 +4,8 @@ #![feature(iter_order_by)] #![feature(option_into_flat_iter)] #![feature(option_reference_flattening)] +#![feature(register_tool)] +#![register_tool(lint)] // tidy-alphabetical-end mod _match; diff --git a/compiler/rustc_index/src/lib.rs b/compiler/rustc_index/src/lib.rs index c84b06769e081..81fc533b6ffc0 100644 --- a/compiler/rustc_index/src/lib.rs +++ b/compiler/rustc_index/src/lib.rs @@ -2,6 +2,8 @@ #![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))] #![cfg_attr(all(feature = "nightly", test), feature(test))] #![cfg_attr(feature = "nightly", feature(extend_one, step_trait))] +#![cfg_attr(feature = "nightly", feature(register_tool))] +#![cfg_attr(feature = "nightly", register_tool(lint))] // tidy-alphabetical-end pub mod bit_set; diff --git a/compiler/rustc_index_macros/src/newtype.rs b/compiler/rustc_index_macros/src/newtype.rs index 52f1d070718e8..05dc588347d7d 100644 --- a/compiler/rustc_index_macros/src/newtype.rs +++ b/compiler/rustc_index_macros/src/newtype.rs @@ -214,7 +214,11 @@ impl Parse for Newtype { Ok(Self(quote! { #(#attrs)* #[derive(Clone, Copy)] - #[cfg_attr(#gate_rustc_only_cfg, rustc_pass_by_value)] + #[cfg_attr( + #gate_rustc_only_cfg, + cfg_attr(bootstrap, rustc_pass_by_value), + cfg_attr(not(bootstrap), lint::pass_by_value) + )] #vis struct #name { #[cfg(not(#gate_rustc_only_cfg))] private_use_as_methods_instead: u32, diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index f2cf938a48385..6c460d298053d 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -15,7 +15,9 @@ // tidy-alphabetical-start #![allow(rustc::direct_use_of_rustc_type_ir)] #![feature(extend_one)] +#![feature(register_tool)] #![recursion_limit = "512"] // For rustdoc +#![register_tool(lint)] // tidy-alphabetical-end mod diagnostics; diff --git a/compiler/rustc_lint/src/autorefs.rs b/compiler/rustc_lint/src/autorefs.rs index 0064e8c6b3a23..33024d0c83314 100644 --- a/compiler/rustc_lint/src/autorefs.rs +++ b/compiler/rustc_lint/src/autorefs.rs @@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitAutorefs { ExprKind::MethodCall(..) => cx.typeck_results().type_dependent_def_id(expr.hir_id), _ => None, } - && method_did.map(|did| find_attr!(cx.tcx, did, RustcNoImplicitAutorefs)).unwrap_or(true) + && method_did.map(|did| find_attr!(cx.tcx, did, LintNoImplicitAutorefs)).unwrap_or(true) { cx.emit_span_lint( DANGEROUS_IMPLICIT_AUTOREFS, diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index b10cd5b4cf6d7..f03d96ce36bce 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -1322,7 +1322,7 @@ pub(crate) struct AttributeKindInFindAttr; #[derive(Diagnostic)] #[diag("match is not exhaustive")] #[help("explicitly list all variants of the enum in a `match`")] -pub(crate) struct RustcMustMatchExhaustivelyNotExhaustive { +pub(crate) struct LintMustMatchExhaustivelyNotExhaustive { #[label("required because of this attribute")] pub attr_span: Span, diff --git a/compiler/rustc_lint/src/disallowed_pass_by_ref.rs b/compiler/rustc_lint/src/disallowed_pass_by_ref.rs index 5939a1da7876a..3234c68148fe0 100644 --- a/compiler/rustc_lint/src/disallowed_pass_by_ref.rs +++ b/compiler/rustc_lint/src/disallowed_pass_by_ref.rs @@ -8,13 +8,13 @@ use crate::diagnostics::DisallowedPassByRefDiag; use crate::{LateContext, LateLintPass, LintContext}; declare_tool_lint! { - /// The `disallowed_pass_by_ref` lint detects if types marked with `#[rustc_pass_by_value]` are + /// The `disallowed_pass_by_ref` lint detects if types marked with `#[lint::pass_by_value)]` are /// passed by reference. Types with this marker are usually thin wrappers around references, so /// there is no benefit to an extra layer of indirection. (Example: `Ty` which is a reference /// to an `Interned`) pub rustc::DISALLOWED_PASS_BY_REF, Warn, - "pass by reference of a type flagged as `#[rustc_pass_by_value]`", + "pass by reference of a type flagged as `#[lint::pass_by_value]`", @report_in_external_macro = true } @@ -27,7 +27,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedPassByRef { if cx.tcx.trait_impl_of_assoc(ty.hir_id.owner.to_def_id()).is_some() { return; } - if let Some(t) = path_for_rustc_pass_by_value(cx, inner_ty) { + if let Some(t) = path_for_pass_by_value(cx, inner_ty) { cx.emit_span_lint( DISALLOWED_PASS_BY_REF, ty.span, @@ -40,10 +40,10 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedPassByRef { } } -fn path_for_rustc_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option { +fn path_for_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option { if let TyKind::Path(QPath::Resolved(_, path)) = &ty.kind { match path.res { - Res::Def(_, def_id) if find_attr!(cx.tcx, def_id, RustcPassByValue) => { + Res::Def(_, def_id) if find_attr!(cx.tcx, def_id, LintPassByValue) => { let name = cx.tcx.item_ident(def_id); let path_segment = path.segments.last().unwrap(); return Some(format!("{}{}", name, gen_args(cx, path_segment))); @@ -52,7 +52,7 @@ fn path_for_rustc_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Optio if let ty::Adt(adt, args) = cx.tcx.type_of(did).instantiate_identity().skip_norm_wip().kind() { - if find_attr!(cx.tcx, adt.did(), RustcPassByValue) { + if find_attr!(cx.tcx, adt.did(), LintPassByValue) { return Some(cx.tcx.def_path_str_with_args(adt.did(), *args)); } } diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 9a425c6167182..5b0a5fa78dbb7 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -18,10 +18,10 @@ use rustc_trait_selection::traits::{Obligation, ObligationCause}; use crate::diagnostics::{ AttributeKindInFindAttr, BadOptAccessDiag, DefaultHashTypesDiag, - ImplicitSysrootCrateImportDiag, LintPassByHand, MissingGenericTypeVisitableDeriveDiag, - NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, - RustcMustMatchExhaustivelyNotExhaustive, SymbolInternStringLiteralDiag, TyQualified, - TykindDiag, TykindKind, TypeIrDirectUse, TypeIrInherentUsage, TypeIrTraitUsage, + ImplicitSysrootCrateImportDiag, LintMustMatchExhaustivelyNotExhaustive, LintPassByHand, + MissingGenericTypeVisitableDeriveDiag, NonGlobImportTypeIrInherent, QueryInstability, + QueryUntracked, SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, + TypeIrDirectUse, TypeIrInherentUsage, TypeIrTraitUsage, }; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; @@ -736,14 +736,14 @@ impl EarlyLintPass for BadUseOfFindAttr { } declare_tool_lint! { - pub rustc::RUSTC_MUST_MATCH_EXHAUSTIVELY, + pub rustc::MUST_MATCH_EXHAUSTIVELY, Allow, - "Forbids matches with wildcards, or if-let matching on enums marked with `#[rustc_must_match_exhaustively]`", + "Forbids matches with wildcards, or if-let matching on enums marked with `#[lint::must_match_exhaustively]`", @report_in_external_macro = true } -declare_lint_pass!(RustcMustMatchExhaustively => [RUSTC_MUST_MATCH_EXHAUSTIVELY]); +declare_lint_pass!(LintMustMatchExhaustively => [MUST_MATCH_EXHAUSTIVELY]); -fn is_rustc_must_match_exhaustively(cx: &LateContext<'_>, id: HirId) -> Option { +fn is_must_match_exhaustively(cx: &LateContext<'_>, id: HirId) -> Option { let res = cx.typeck_results(); let ty = res.node_type(id); @@ -753,7 +753,7 @@ fn is_rustc_must_match_exhaustively(cx: &LateContext<'_>, id: HirId) -> Option *span) + find_attr!(cx.tcx, adt_def.did(), LintMustMatchExhaustively(span) => *span) } else { None } @@ -780,19 +780,19 @@ fn pat_is_not_exhaustive_heuristic(pat: &hir::Pat<'_>) -> Option<(Span, &'static } } -impl<'tcx> LateLintPass<'tcx> for RustcMustMatchExhaustively { +impl<'tcx> LateLintPass<'tcx> for LintMustMatchExhaustively { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) { match expr.kind { // This is not perfect exhaustiveness checking, that's why this is just a rustc internal // attribute. But it catches most reasonable cases hir::ExprKind::Match(expr, arms, _) => { - if let Some(attr_span) = is_rustc_must_match_exhaustively(cx, expr.hir_id) { + if let Some(attr_span) = is_must_match_exhaustively(cx, expr.hir_id) { for arm in arms { if let Some((span, message)) = pat_is_not_exhaustive_heuristic(arm.pat) { cx.emit_span_lint( - RUSTC_MUST_MATCH_EXHAUSTIVELY, + MUST_MATCH_EXHAUSTIVELY, expr.span, - RustcMustMatchExhaustivelyNotExhaustive { + LintMustMatchExhaustivelyNotExhaustive { attr_span, pat_span: span, message, @@ -803,11 +803,11 @@ impl<'tcx> LateLintPass<'tcx> for RustcMustMatchExhaustively { } } hir::ExprKind::Let(expr, ..) => { - if let Some(attr_span) = is_rustc_must_match_exhaustively(cx, expr.init.hir_id) { + if let Some(attr_span) = is_must_match_exhaustively(cx, expr.init.hir_id) { cx.emit_span_lint( - RUSTC_MUST_MATCH_EXHAUSTIVELY, + MUST_MATCH_EXHAUSTIVELY, expr.span, - RustcMustMatchExhaustivelyNotExhaustive { + LintMustMatchExhaustivelyNotExhaustive { attr_span, pat_span: expr.span, message: "using `if let` only matches on one variant (try using `match`)", @@ -823,13 +823,12 @@ impl<'tcx> LateLintPass<'tcx> for RustcMustMatchExhaustively { match stmt.kind { rustc_hir::StmtKind::Let(let_stmt) => { if let_stmt.els.is_some() - && let Some(attr_span) = - is_rustc_must_match_exhaustively(cx, let_stmt.pat.hir_id) + && let Some(attr_span) = is_must_match_exhaustively(cx, let_stmt.pat.hir_id) { cx.emit_span_lint( - RUSTC_MUST_MATCH_EXHAUSTIVELY, + MUST_MATCH_EXHAUSTIVELY, let_stmt.span, - RustcMustMatchExhaustivelyNotExhaustive { + LintMustMatchExhaustivelyNotExhaustive { attr_span, pat_span: let_stmt.pat.span, message: "using `let else` only matches on one variant (try using `match`)", diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 971c75608f73e..b553b01f84fa5 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -25,7 +25,9 @@ #![feature(deref_patterns)] #![feature(iter_order_by)] #![feature(option_into_flat_iter)] +#![feature(register_tool)] #![feature(try_blocks)] +#![register_tool(lint)] // tidy-alphabetical-end mod async_closures; @@ -302,9 +304,9 @@ late_lint_methods!( BadOptAccess: BadOptAccess, DefaultHashTypes: DefaultHashTypes, DisallowedPassByRef: DisallowedPassByRef, + LintMustMatchExhaustively: LintMustMatchExhaustively, MissingGenericTypeVisitableDerive: MissingGenericTypeVisitableDerive, QueryStability: QueryStability, - RustcMustMatchExhaustively: RustcMustMatchExhaustively, SymbolInternStringLiteral: SymbolInternStringLiteral, TyTyKind: TyTyKind, TypeIr: TypeIr, @@ -776,8 +778,8 @@ fn register_internals(store: &mut LintStore) { // `warn(symbol_intern_string_literal)` is used. // LintId::of(SYMBOL_INTERN_STRING_LITERAL), // - // Late pass: RustcMustMatchExhaustively - LintId::of(RUSTC_MUST_MATCH_EXHAUSTIVELY), + // Late pass: LintMustMatchExhaustively + LintId::of(MUST_MATCH_EXHAUSTIVELY), // Late pass: MissingGenericTypeVisitableDerive // Note: this one is not included so that it doesn't become effectively warn-by-default // (since `rustc::internal` is warn-by-default). Instead, it's enabled manually in diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 1706fece29a8b..37ef4aa6f59fa 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -7,7 +7,9 @@ #![feature(min_specialization)] #![feature(option_into_flat_iter)] #![feature(proc_macro_internals)] +#![feature(register_tool)] #![feature(trusted_len)] +#![register_tool(lint)] // tidy-alphabetical-end pub use rmeta::provide; diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 5d69dadf4ade0..359e33c0552db 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -46,6 +46,7 @@ #![feature(negative_impls)] #![feature(option_into_flat_iter)] #![feature(range_bounds_is_empty)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![feature(sized_hierarchy)] #![feature(trait_alias)] @@ -57,6 +58,7 @@ #![feature(variant_count)] #![feature(yeet_expr)] #![recursion_limit = "256"] +#![register_tool(lint)] // tidy-alphabetical-end #[cfg(test)] diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index d0e35ad80bfb0..6842bfeb94637 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -282,7 +282,8 @@ impl hash::Hash for Allocation { /// means that both the inner type (`Allocation`) and the outer type /// (`ConstAllocation`) are used quite a bit. #[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct ConstAllocation<'tcx>(pub Interned<'tcx, Allocation>); impl<'tcx> fmt::Debug for ConstAllocation<'tcx> { diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 7db6a7390d539..ceb8ac6f57941 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -486,7 +486,8 @@ pub enum NonDivergingIntrinsic<'tcx> { /// Describes whether this operand use performs a retag. #[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub enum WithRetag { Yes, No, diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index e93059f5216c2..abe94135bb516 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -183,7 +183,8 @@ impl StableHash for AdtDefData { } #[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct AdtDef<'tcx>(pub Interned<'tcx, AdtDefData>); impl<'tcx> AdtDef<'tcx> { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index cb26e7b14e0ff..0569d810f239e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -919,7 +919,8 @@ pub struct GlobalCaches<'tcx> { /// possible. #[derive(Copy, Clone)] #[rustc_diagnostic_item = "TyCtxt"] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct TyCtxt<'tcx> { gcx: &'tcx GlobalCtxt<'tcx>, } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 53e4cf0f92e89..9f9383c939cb4 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -521,7 +521,8 @@ pub struct CReaderCacheKey { /// Use this rather than `TyKind`, whenever possible. #[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] #[rustc_diagnostic_item = "Ty"] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo>>); impl<'tcx> rustc_type_ir::inherent::IntoKind for Ty<'tcx> { diff --git a/compiler/rustc_middle/src/ty/pattern.rs b/compiler/rustc_middle/src/ty/pattern.rs index 2d73124265fc2..912908d984621 100644 --- a/compiler/rustc_middle/src/ty/pattern.rs +++ b/compiler/rustc_middle/src/ty/pattern.rs @@ -11,7 +11,8 @@ use crate::ty; pub type PatternKind<'tcx> = ir::PatternKind>; #[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct Pattern<'tcx>(pub Interned<'tcx, PatternKind<'tcx>>); impl<'tcx> Flags for Pattern<'tcx> { diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 7870b20c7d304..52ac0c512f82f 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -42,7 +42,8 @@ pub type PolyProjectionClause<'tcx> = ty::Binder<'tcx, ProjectionClause<'tcx>>; /// /// Use this rather than `PredicateKind`, whenever possible. #[derive(Clone, Copy, PartialEq, Eq, Hash, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct Predicate<'tcx>( pub(super) Interned<'tcx, WithCachedTypeInfo>>>, ); @@ -132,7 +133,8 @@ impl<'tcx> rustc_errors::IntoDiagArg for Clause<'tcx> { /// an item's where clauses, hence the name `Clause`, and may either be user-written /// (such as traits) or may be inserted during lowering. #[derive(Clone, Copy, PartialEq, Eq, Hash, StableHash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] pub struct Clause<'tcx>( pub(super) Interned<'tcx, WithCachedTypeInfo>>>, ); diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 78be159b08292..c321b5e5d8217 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -2,7 +2,9 @@ // tidy-alphabetical-start #![feature(deref_patterns)] +#![feature(register_tool)] #![feature(try_blocks)] +#![register_tool(lint)] // tidy-alphabetical-end // The `builder` module used to be named `build`, but that was causing GitHub's diff --git a/compiler/rustc_mir_dataflow/src/lib.rs b/compiler/rustc_mir_dataflow/src/lib.rs index cd42f5f23f7a4..f71e8f6a476d3 100644 --- a/compiler/rustc_mir_dataflow/src/lib.rs +++ b/compiler/rustc_mir_dataflow/src/lib.rs @@ -3,6 +3,8 @@ #![feature(deref_patterns)] #![feature(exact_size_is_empty)] #![feature(file_buffered)] +#![feature(register_tool)] +#![register_tool(lint)] // tidy-alphabetical-end use rustc_middle::ty; diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 6422ddc5fa393..9f79de54e3555 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -775,11 +775,11 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> { let param_def = generics.param_at(index, self.tcx); if let GenericParamDefKind::Const { .. } = param_def.kind - && find_attr!(self.tcx, param_def.def_id, RustcPanicsWhenZero) + && find_attr!(self.tcx, param_def.def_id, LintPanicsWhenZero) && let Some(0) = ct.try_to_target_usize(self.tcx) { // We managed to figure-out that the value of a - // `#[rustc_panics_when_zero]` const-generic parameter is zero. + // `#[lint::panics_when_zero]` const-generic parameter is zero. // // Let's report it as an unconditional panic. let source_info = self.body.source_info(location); diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index e8788854a8d82..ed1076f1150c9 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -5,8 +5,10 @@ #![feature(impl_trait_in_assoc_type)] #![feature(iterator_try_collect)] #![feature(option_into_flat_iter)] +#![feature(register_tool)] #![feature(try_blocks)] #![feature(yeet_expr)] +#![register_tool(lint)] // tidy-alphabetical-end use hir::ConstContext; diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index ec52a837e1a51..fc23fb0815bff 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -2,6 +2,8 @@ #![feature(file_buffered)] #![feature(impl_trait_in_assoc_type)] #![feature(once_cell_get_mut)] +#![feature(register_tool)] +#![register_tool(lint)] // tidy-alphabetical-end use rustc_attr_ir::lang_items::LangItem; diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index a20dc90f72908..a2ea55a285c4a 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -256,7 +256,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::LinkOrdinal { .. } => (), AttributeKind::LinkSection { .. } => (), AttributeKind::LintAsPtr => (), + AttributeKind::LintMustMatchExhaustively(..) => (), AttributeKind::LintNeverReturnsNullPtr => (), + AttributeKind::LintNoImplicitAutorefs => (), + AttributeKind::LintPanicsWhenZero => (), + AttributeKind::LintPassByValue => (), AttributeKind::LintShouldNotBeCalledOnConstItems => (), AttributeKind::LoopMatch(..) => (), AttributeKind::MacroEscape => (), @@ -355,8 +359,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::RustcMacroTransparency(_) => (), AttributeKind::RustcMain => (), AttributeKind::RustcMir(_) => (), - AttributeKind::RustcMustMatchExhaustively(..) => (), - AttributeKind::RustcNoImplicitAutorefs => (), AttributeKind::RustcNoImplicitBounds => (), AttributeKind::RustcNoMirInline => (), AttributeKind::RustcNoWritable => (), @@ -366,9 +368,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::RustcObjcClass { .. } => (), AttributeKind::RustcObjcSelector { .. } => (), AttributeKind::RustcOffloadKernel => (), - AttributeKind::RustcPanicsWhenZero => (), AttributeKind::RustcParenSugar => (), - AttributeKind::RustcPassByValue => (), AttributeKind::RustcPassIndirectlyInNonRusticAbis(..) => (), AttributeKind::RustcPreserveUbChecks => (), AttributeKind::RustcProcMacroDecls => (), diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 37068c3b55d6d..2003b5a4457d7 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -170,25 +170,16 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { ItemKind::MacroDef(ident, def) => { let edition = i.span.edition(); - // FIXME(jdonszelmann) make one of these in the resolver? - // FIXME(jdonszelmann) don't care about tools here maybe? Just parse what we can. - // Does that prevents errors from happening? maybe - let mut parser = AttributeParser::new( + let attrs = AttributeParser::parse_limited_all( &self.r.tcx.sess, - self.r.features, - self.r.tcx().registered_attr_tools(()), - ShouldEmit::Nothing, - ); - let attrs = parser.parse_attribute_list( &i.attrs, - i.span, + None, AstTarget::from_ast_item(&i.kind), - std::convert::identity, - |_lint_id, _span, _kind| { - // FIXME(jdonszelmann): emit lints here properly - // NOTE that before new attribute parsing, they didn't happen either - // but it would be nice if we could change that. - }, + i.span, + i.id, + Some(self.r.features), + ShouldEmit::Nothing, + Some(self.r.tcx().registered_attr_tools(())), ); let ext = self.r.compile_macro(def, *ident, &attrs, i.span, i.id, edition); diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index ef368af85f017..07f03fb3b4660 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -16,8 +16,10 @@ #![feature(deref_patterns)] #![feature(iter_intersperse)] #![feature(option_into_flat_iter)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![recursion_limit = "256"] +#![register_tool(lint)] // tidy-alphabetical-end use std::cell::RefMut; @@ -738,17 +740,20 @@ struct ModuleData<'ra> { /// `Interned` is used because values of this type have "identity" and compare as unequal even if /// they have the same contents. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] struct Module<'ra>(Interned<'ra, ModuleData<'ra>>); /// Same as `Module`, but is guaranteed to be from the current crate. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] struct LocalModule<'ra>(Interned<'ra, ModuleData<'ra>>); /// Same as `Module`, but is guaranteed to be from an external crate. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] struct ExternModule<'ra>(Interned<'ra, ModuleData<'ra>>); impl<'ra> ModuleData<'ra> { diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 9134e652987c9..627d43a83e5e7 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -239,7 +239,8 @@ rustc_index::newtype_index! { // On below-64 bit systems we can simply use the derived `Hash` impl #[cfg_attr(not(target_pointer_width = "64"), derive(Hash))] #[repr(C)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] // We guarantee field order. Note that the order is essential here, see below why. pub struct DefId { // cfg-ing the order of fields so that the `DefIndex` which is high entropy always ends up in diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 2d9e827032669..f4b02ee153385 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -23,8 +23,10 @@ #![feature(map_try_insert)] #![feature(negative_impls)] #![feature(read_buf)] +#![feature(register_tool)] #![feature(rustc_attrs)] #![feature(trait_alias)] +#![register_tool(lint)] // tidy-alphabetical-end // The code produced by the `Encodable`/`Decodable` derive macros refer to diff --git a/compiler/rustc_span/src/span_encoding.rs b/compiler/rustc_span/src/span_encoding.rs index 1b8569b5a7fde..2d97581abe7d8 100644 --- a/compiler/rustc_span/src/span_encoding.rs +++ b/compiler/rustc_span/src/span_encoding.rs @@ -88,7 +88,8 @@ use crate::{BytePos, SPAN_TRACK, SpanData}; /// accesses to `lo` and `hi` must introduce a dependency to the parent definition's span. /// This is performed using the callback `SPAN_TRACK` to access the query engine. #[derive(Clone, Copy, Eq, PartialEq, Hash)] -#[rustc_pass_by_value] +#[cfg_attr(bootstrap, rustc_pass_by_value)] +#[cfg_attr(not(bootstrap), lint::pass_by_value)] #[repr(packed(4))] pub struct Span(u64); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 839c7952b9096..e9d14a4d0dddb 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1415,6 +1415,7 @@ symbols! { mul_assign, mul_with_overflow, multiple_supertrait_upcastable, + must_match_exhaustively, must_not_suspend, must_use, mut_preserve_binding_mode_2024, @@ -1473,6 +1474,7 @@ symbols! { no_crate_inject, no_debug, no_default_passes, + no_implicit_autorefs, no_implicit_prelude, no_inline, no_link, @@ -1591,11 +1593,13 @@ symbols! { panic_str_2015, panic_unwind, panicking, + panics_when_zero, param_attrs, parent_label, partial_cmp, partial_eq, partial_ord, + pass_by_value, passes, pat, pat_param, @@ -1867,8 +1871,6 @@ symbols! { rustc_main, rustc_mir, rustc_must_implement_one_of, - rustc_must_match_exhaustively, - rustc_no_implicit_autorefs, rustc_no_implicit_bounds, rustc_no_mir_inline, rustc_no_writable, @@ -1879,11 +1881,9 @@ symbols! { rustc_objc_selector, rustc_offload_kernel, rustc_on_unimplemented, - rustc_panics_when_zero, rustc_paren_sugar, rustc_partition_codegened, rustc_partition_reused, - rustc_pass_by_value, rustc_pass_indirectly_in_non_rustic_abis, rustc_peek, rustc_peek_liveness, diff --git a/compiler/rustc_type_ir/src/error.rs b/compiler/rustc_type_ir/src/error.rs index 76b86d21b6ae4..2a5bbb617e93d 100644 --- a/compiler/rustc_type_ir/src/error.rs +++ b/compiler/rustc_type_ir/src/error.rs @@ -21,7 +21,11 @@ impl ExpectedFound { // Data structures used in type unification #[derive_where(Clone, Copy, PartialEq, Debug; I: Interner)] #[derive(TypeVisitable_Generic, GenericTypeVisitable)] -#[cfg_attr(feature = "nightly", rustc_pass_by_value)] +#[cfg_attr( + feature = "nightly", + cfg_attr(bootstrap, rustc_pass_by_value), + cfg_attr(not(bootstrap), lint::pass_by_value) +)] pub enum TypeError { Mismatch, PolarityMismatch(#[type_visitable(ignore)] ExpectedFound), diff --git a/compiler/rustc_type_ir/src/infer_ctxt.rs b/compiler/rustc_type_ir/src/infer_ctxt.rs index 682bc8ef03a39..f11c06ef78e13 100644 --- a/compiler/rustc_type_ir/src/infer_ctxt.rs +++ b/compiler/rustc_type_ir/src/infer_ctxt.rs @@ -57,7 +57,7 @@ impl TypingModeErasedStatus for MayBeErased {} /// Hence, `TypingMode` does not implement `Eq`, though [`TypingModeEqWrapper`] is available /// in the rare case that you do need this. Most cases where this currently matters is /// where we pass typing modes through the query system and want to cache based on it. -/// See also `#[rustc_must_match_exhaustively]`, which tries to detect non-exhaustive +/// See also `#[lint::must_match_exhaustively]`, which tries to detect non-exhaustive /// matches. /// /// Since matching on typing mode to single out `Coherence` is so common, and `Coherence` @@ -67,7 +67,11 @@ impl TypingModeErasedStatus for MayBeErased {} feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash_NoContext) )] -#[cfg_attr(feature = "nightly", rustc_must_match_exhaustively)] +#[cfg_attr( + feature = "nightly", + cfg_attr(bootstrap, rustc_must_match_exhaustively), + cfg_attr(not(bootstrap), lint::must_match_exhaustively) +)] pub enum TypingMode { /// When checking whether impls overlap, we check whether any obligations /// are guaranteed to never hold when unifying the impls. This requires us diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index ef258e3b18321..e800f08c73b78 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -26,7 +26,11 @@ #![allow(rustc::usage_of_type_ir_inherent)] #![allow(rustc::usage_of_type_ir_traits)] #![cfg_attr(feature = "nightly", allow(internal_features))] -#![cfg_attr(feature = "nightly", feature(associated_type_defaults, rustc_attrs, negative_impls))] +#![cfg_attr(feature = "nightly", feature(associated_type_defaults))] +#![cfg_attr(feature = "nightly", feature(negative_impls))] +#![cfg_attr(feature = "nightly", feature(register_tool))] +#![cfg_attr(feature = "nightly", feature(rustc_attrs))] +#![cfg_attr(feature = "nightly", register_tool(lint))] #![deny(rustc::missing_generic_type_visitable_derive)] // tidy-alphabetical-end @@ -256,7 +260,11 @@ pub fn debug_bound_var( #[derive(Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "nightly", derive(Decodable, Encodable, StableHash))] -#[cfg_attr(feature = "nightly", rustc_pass_by_value)] +#[cfg_attr( + feature = "nightly", + cfg_attr(bootstrap, rustc_pass_by_value), + cfg_attr(not(bootstrap), lint::pass_by_value) +)] pub enum Variance { Covariant, // T <: T iff A <: B -- e.g., function return type Invariant, // T <: T iff B == A -- e.g., type of mutable cell diff --git a/compiler/rustc_type_ir/src/sty/consts.rs b/compiler/rustc_type_ir/src/sty/consts.rs index 65cce0aa20481..ce9917bb5a9c4 100644 --- a/compiler/rustc_type_ir/src/sty/consts.rs +++ b/compiler/rustc_type_ir/src/sty/consts.rs @@ -19,7 +19,11 @@ use crate::{ #[derive_where(Clone, Copy, PartialEq, Eq, Hash; I: Interner)] #[cfg_attr(feature = "nightly", derive(StableHash_NoContext))] -#[cfg_attr(feature = "nightly", rustc_pass_by_value)] +#[cfg_attr( + feature = "nightly", + cfg_attr(bootstrap, rustc_pass_by_value), + cfg_attr(not(bootstrap), lint::pass_by_value) +)] #[derive(GenericTypeVisitable, Lift_Generic)] pub struct Const(pub I::InternedConstKind); diff --git a/compiler/rustc_type_ir/src/sty/mod.rs b/compiler/rustc_type_ir/src/sty/mod.rs index d513dd88faae6..15b4a6934d06b 100644 --- a/compiler/rustc_type_ir/src/sty/mod.rs +++ b/compiler/rustc_type_ir/src/sty/mod.rs @@ -21,7 +21,11 @@ use crate::{ /// Use this rather than `RegionKind`, whenever possible. #[derive_where(Clone, Copy, PartialEq, Eq, Hash; I: Interner)] #[cfg_attr(feature = "nightly", derive(StableHash_NoContext))] -#[cfg_attr(feature = "nightly", rustc_pass_by_value)] +#[cfg_attr( + feature = "nightly", + cfg_attr(bootstrap, rustc_pass_by_value), + cfg_attr(not(bootstrap), lint::pass_by_value) +)] #[derive(GenericTypeVisitable, Lift_Generic)] pub struct Region(pub I::InternedRegionKind); diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 1e3861b3cb933..f15c65d490d6c 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -1910,7 +1910,7 @@ impl String { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_vec_string_slice", since = "1.87.0")] #[rustc_confusables("length", "size")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] pub const fn len(&self) -> usize { self.vec.len() } @@ -1930,7 +1930,7 @@ impl String { #[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_vec_string_slice", since = "1.87.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] pub const fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 98c65efc4e58e..21714f50f8e9a 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1789,7 +1789,7 @@ pub const trait Iterator { /// ``` #[inline] #[unstable(feature = "iter_map_windows", issue = "87155")] - fn map_windows( + fn map_windows( self, f: F, ) -> MapWindows @@ -3675,7 +3675,7 @@ pub const trait Iterator { #[track_caller] #[unstable(feature = "iter_array_chunks", issue = "100450")] #[rustc_diagnostic_item = "iter_array_chunks"] - fn array_chunks<#[rustc_panics_when_zero] const N: usize>(self) -> ArrayChunks + fn array_chunks<#[lint::panics_when_zero] const N: usize>(self) -> ArrayChunks where Self: Sized, { diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 2c62a3930c281..c180b82eea2b5 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -68,7 +68,7 @@ pub const trait Index { /// /// May panic if the index is out of bounds. #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[track_caller] fn index(&self, index: Idx) -> &Self::Output; } @@ -174,7 +174,7 @@ pub const trait IndexMut: [const] Index { /// /// May panic if the index is out of bounds. #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[track_caller] fn index_mut(&mut self, index: Idx) -> &mut Self::Output; } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index ca90bdb60efac..c212df6459e24 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -112,7 +112,7 @@ impl [T] { #[lang = "slice_len_fn"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[inline] #[must_use] pub const fn len(&self) -> usize { @@ -132,7 +132,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_slice_is_empty", since = "1.39.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[inline] #[must_use] pub const fn is_empty(&self) -> bool { @@ -587,7 +587,7 @@ impl [T] { /// assert_eq!(None, v.get(0..4)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[inline] #[must_use] #[rustc_const_unstable(feature = "const_index", issue = "143775")] @@ -614,7 +614,7 @@ impl [T] { /// assert_eq!(x, &[0, 42, 2]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[inline] #[must_use] #[rustc_const_unstable(feature = "const_index", issue = "143775")] @@ -654,7 +654,7 @@ impl [T] { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[inline] #[must_use] #[track_caller] @@ -699,7 +699,7 @@ impl [T] { /// assert_eq!(x, &[1, 13, 4]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[inline] #[must_use] #[track_caller] @@ -1356,7 +1356,7 @@ impl [T] { #[inline] #[must_use] #[track_caller] - pub const unsafe fn as_chunks_unchecked<#[rustc_panics_when_zero] const N: usize>( + pub const unsafe fn as_chunks_unchecked<#[lint::panics_when_zero] const N: usize>( &self, ) -> &[[T; N]] { assert_unsafe_precondition!( @@ -1416,7 +1416,7 @@ impl [T] { #[inline] #[track_caller] #[must_use] - pub const fn as_chunks<#[rustc_panics_when_zero] const N: usize>(&self) -> (&[[T; N]], &[T]) { + pub const fn as_chunks<#[lint::panics_when_zero] const N: usize>(&self) -> (&[[T; N]], &[T]) { assert!(N != 0, "chunk size must be non-zero"); let len_rounded_down = self.len() / N * N; // SAFETY: The rounded-down value is always the same or smaller than the @@ -1463,7 +1463,7 @@ impl [T] { #[inline] #[track_caller] #[must_use] - pub const fn as_rchunks<#[rustc_panics_when_zero] const N: usize>(&self) -> (&[T], &[[T; N]]) { + pub const fn as_rchunks<#[lint::panics_when_zero] const N: usize>(&self) -> (&[T], &[[T; N]]) { assert!(N != 0, "chunk size must be non-zero"); let len = self.len() / N; let (remainder, multiple_of_n) = self.split_at(self.len() - len * N); @@ -1518,7 +1518,7 @@ impl [T] { #[inline] #[must_use] #[track_caller] - pub const unsafe fn as_chunks_unchecked_mut<#[rustc_panics_when_zero] const N: usize>( + pub const unsafe fn as_chunks_unchecked_mut<#[lint::panics_when_zero] const N: usize>( &mut self, ) -> &mut [[T; N]] { assert_unsafe_precondition!( @@ -1574,7 +1574,7 @@ impl [T] { #[inline] #[track_caller] #[must_use] - pub const fn as_chunks_mut<#[rustc_panics_when_zero] const N: usize>( + pub const fn as_chunks_mut<#[lint::panics_when_zero] const N: usize>( &mut self, ) -> (&mut [[T; N]], &mut [T]) { assert!(N != 0, "chunk size must be non-zero"); @@ -1629,7 +1629,7 @@ impl [T] { #[inline] #[track_caller] #[must_use] - pub const fn as_rchunks_mut<#[rustc_panics_when_zero] const N: usize>( + pub const fn as_rchunks_mut<#[lint::panics_when_zero] const N: usize>( &mut self, ) -> (&mut [T], &mut [[T; N]]) { assert!(N != 0, "chunk size must be non-zero"); @@ -1672,7 +1672,7 @@ impl [T] { #[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")] #[inline] #[track_caller] - pub const fn array_windows<#[rustc_panics_when_zero] const N: usize>( + pub const fn array_windows<#[lint::panics_when_zero] const N: usize>( &self, ) -> ArrayWindows<'_, T, N> { assert!(N != 0, "window size must be non-zero"); diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 01c93465ca251..f76a3828bd6f9 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -148,7 +148,7 @@ impl str { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_str_len", since = "1.39.0")] #[rustc_diagnostic_item = "str_len"] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[must_use] #[inline] #[allow(clippy::needless_as_bytes)] @@ -169,7 +169,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_str_is_empty", since = "1.39.0")] - #[rustc_no_implicit_autorefs] + #[lint::no_implicit_autorefs] #[must_use] #[inline] pub const fn is_empty(&self) -> bool { diff --git a/tests/crashes/141293.rs b/tests/crashes/141293.rs index 07ade1eb6edea..7ac63989b5997 100644 --- a/tests/crashes/141293.rs +++ b/tests/crashes/141293.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ known-bug: #141293 #![feature(unsafe_binders)] type X = unsafe (); diff --git a/tests/crashes/154367.rs b/tests/crashes/154367.rs index 54e55ffd96ae9..678d5d7c78c0b 100644 --- a/tests/crashes/154367.rs +++ b/tests/crashes/154367.rs @@ -1,4 +1,5 @@ //@ known-bug: #154367 +//@ compile-flags: -Znext-solver //@ compile-flags: -Copt-level=0 #![feature(unsafe_binders)] diff --git a/tests/debuginfo/unsafe-binders.rs b/tests/debuginfo/unsafe-binders.rs index cd6c87052f2d8..c6382095be044 100644 --- a/tests/debuginfo/unsafe-binders.rs +++ b/tests/debuginfo/unsafe-binders.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ compile-flags: -g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc diff --git a/tests/mir-opt/gvn_on_unsafe_binder.rs b/tests/mir-opt/gvn_on_unsafe_binder.rs index 81289c50c9957..0032992cd03bb 100644 --- a/tests/mir-opt/gvn_on_unsafe_binder.rs +++ b/tests/mir-opt/gvn_on_unsafe_binder.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ skip-filecheck //@ test-mir-pass: GVN diff --git a/tests/rustdoc-html/auxiliary/unsafe-binder-dep.rs b/tests/rustdoc-html/auxiliary/unsafe-binder-dep.rs index 65aa9032fed19..62f6890a1b988 100644 --- a/tests/rustdoc-html/auxiliary/unsafe-binder-dep.rs +++ b/tests/rustdoc-html/auxiliary/unsafe-binder-dep.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] #![allow(incomplete_features)] diff --git a/tests/rustdoc-html/unsafe-binder.rs b/tests/rustdoc-html/unsafe-binder.rs index 621c3dadc72ee..c882870da43f0 100644 --- a/tests/rustdoc-html/unsafe-binder.rs +++ b/tests/rustdoc-html/unsafe-binder.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ aux-build:unsafe-binder-dep.rs #![feature(unsafe_binders)] diff --git a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value.rs b/tests/ui-fulldeps/internal-lints/disallowed_pass_by_ref.rs similarity index 93% rename from tests/ui-fulldeps/internal-lints/rustc_pass_by_value.rs rename to tests/ui-fulldeps/internal-lints/disallowed_pass_by_ref.rs index 42d75be966840..9395d20773433 100644 --- a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value.rs +++ b/tests/ui-fulldeps/internal-lints/disallowed_pass_by_ref.rs @@ -1,9 +1,11 @@ //@ compile-flags: -Z unstable-options -//@ ignore-stage1 (this can be removed when nightly goes to 1.96) +//@ ignore-stage1 (this can be removed in 2027) #![feature(rustc_attrs)] #![feature(rustc_private)] +#![feature(register_tool)] #![deny(rustc::disallowed_pass_by_ref)] #![allow(unused)] +#![register_tool(lint)] extern crate rustc_middle; @@ -62,7 +64,7 @@ impl Foo { //~^^ ERROR passing `TyCtxt<'_>` by reference } -#[rustc_pass_by_value] +#[lint::pass_by_value] enum CustomEnum { A, B, @@ -76,12 +78,12 @@ impl CustomEnum { } } -#[rustc_pass_by_value] +#[lint::pass_by_value] struct CustomStruct { s: u8, } -#[rustc_pass_by_value] +#[lint::pass_by_value] type CustomAlias<'a> = &'a CustomStruct; //~ ERROR passing `CustomStruct` by reference impl CustomStruct { @@ -98,7 +100,7 @@ impl CustomStruct { } } -#[rustc_pass_by_value] +#[lint::pass_by_value] struct WithParameters { slice: [T; N], m: M, diff --git a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value.stderr b/tests/ui-fulldeps/internal-lints/disallowed_pass_by_ref.stderr similarity index 81% rename from tests/ui-fulldeps/internal-lints/rustc_pass_by_value.stderr rename to tests/ui-fulldeps/internal-lints/disallowed_pass_by_ref.stderr index b2906ea1e1195..b91fd8d0db562 100644 --- a/tests/ui-fulldeps/internal-lints/rustc_pass_by_value.stderr +++ b/tests/ui-fulldeps/internal-lints/disallowed_pass_by_ref.stderr @@ -1,125 +1,125 @@ error: passing `Ty<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:14:13 + --> $DIR/disallowed_pass_by_ref.rs:16:13 | LL | ty_ref: &Ty<'_>, | ^^^^^^^ help: try passing by value: `Ty<'_>` | note: the lint level is defined here - --> $DIR/rustc_pass_by_value.rs:5:9 + --> $DIR/disallowed_pass_by_ref.rs:6:9 | LL | #![deny(rustc::disallowed_pass_by_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: passing `TyCtxt<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:16:18 + --> $DIR/disallowed_pass_by_ref.rs:18:18 | LL | ty_ctxt_ref: &TyCtxt<'_>, | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:20:28 + --> $DIR/disallowed_pass_by_ref.rs:22:28 | LL | fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} | ^^^^^^^ help: try passing by value: `Ty<'_>` error: passing `TyCtxt<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:20:55 + --> $DIR/disallowed_pass_by_ref.rs:22:55 | LL | fn ty_multi_ref(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:27:17 + --> $DIR/disallowed_pass_by_ref.rs:29:17 | LL | ty_ref: &Ty<'_>, | ^^^^^^^ help: try passing by value: `Ty<'_>` error: passing `TyCtxt<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:29:22 + --> $DIR/disallowed_pass_by_ref.rs:31:22 | LL | ty_ctxt_ref: &TyCtxt<'_>, | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:32:41 + --> $DIR/disallowed_pass_by_ref.rs:34:41 | LL | fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>); | ^^^^^^^ help: try passing by value: `Ty<'_>` error: passing `TyCtxt<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:32:68 + --> $DIR/disallowed_pass_by_ref.rs:34:68 | LL | fn ty_multi_ref_in_trait(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>); | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:54:17 + --> $DIR/disallowed_pass_by_ref.rs:56:17 | LL | ty_ref: &Ty<'_>, | ^^^^^^^ help: try passing by value: `Ty<'_>` error: passing `TyCtxt<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:56:22 + --> $DIR/disallowed_pass_by_ref.rs:58:22 | LL | ty_ctxt_ref: &TyCtxt<'_>, | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `Ty<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:60:38 + --> $DIR/disallowed_pass_by_ref.rs:62:38 | LL | fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} | ^^^^^^^ help: try passing by value: `Ty<'_>` error: passing `TyCtxt<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:60:65 + --> $DIR/disallowed_pass_by_ref.rs:62:65 | LL | fn ty_multi_ref_assoc(ty_multi: &&Ty<'_>, ty_ctxt_multi: &&&&TyCtxt<'_>) {} | ^^^^^^^^^^^ help: try passing by value: `TyCtxt<'_>` error: passing `CustomEnum` by reference - --> $DIR/rustc_pass_by_value.rs:74:20 + --> $DIR/disallowed_pass_by_ref.rs:76:20 | LL | reference: &CustomEnum, | ^^^^^^^^^^^ help: try passing by value: `CustomEnum` error: passing `CustomStruct` by reference - --> $DIR/rustc_pass_by_value.rs:85:24 + --> $DIR/disallowed_pass_by_ref.rs:87:24 | LL | type CustomAlias<'a> = &'a CustomStruct; | ^^^^^^^^^^^^^^^^ help: try passing by value: `CustomStruct` error: passing `CustomStruct` by reference - --> $DIR/rustc_pass_by_value.rs:90:20 + --> $DIR/disallowed_pass_by_ref.rs:92:20 | LL | reference: &CustomStruct, | ^^^^^^^^^^^^^ help: try passing by value: `CustomStruct` error: passing `CustomAlias<'_>` by reference - --> $DIR/rustc_pass_by_value.rs:96:20 + --> $DIR/disallowed_pass_by_ref.rs:98:20 | LL | reference: &CustomAlias, | ^^^^^^^^^^^^ help: try passing by value: `CustomAlias<'_>` error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value.rs:110:20 + --> $DIR/disallowed_pass_by_ref.rs:112:20 | LL | reference: &'a WithParameters, | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try passing by value: `WithParameters` error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value.rs:111:27 + --> $DIR/disallowed_pass_by_ref.rs:113:27 | LL | reference_with_m: &WithParameters, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try passing by value: `WithParameters` error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value.rs:112:10 + --> $DIR/disallowed_pass_by_ref.rs:114:10 | LL | ) -> &'a WithParameters { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try passing by value: `WithParameters` error: passing `WithParameters<_, 1>` by reference - --> $DIR/rustc_pass_by_value.rs:114:22 + --> $DIR/disallowed_pass_by_ref.rs:116:22 | LL | reference as &WithParameters<_, 1> | ^^^^^^^^^^^^^^^^^^^^^ help: try passing by value: `WithParameters<_, 1>` diff --git a/tests/ui-fulldeps/internal-lints/must_match_exhaustively.rs b/tests/ui-fulldeps/internal-lints/must_match_exhaustively.rs index 0752ee1a6c00c..2235215faf583 100644 --- a/tests/ui-fulldeps/internal-lints/must_match_exhaustively.rs +++ b/tests/ui-fulldeps/internal-lints/must_match_exhaustively.rs @@ -2,10 +2,13 @@ //@ ignore-stage1 #![feature(rustc_private)] +#![feature(register_tool)] #![feature(rustc_attrs)] -#![deny(rustc::rustc_must_match_exhaustively)] +#![register_tool(lint)] -#[rustc_must_match_exhaustively] +#![deny(rustc::must_match_exhaustively)] + +#[lint::must_match_exhaustively] #[derive(Copy, Clone)] enum Foo { A { field: u32 }, diff --git a/tests/ui-fulldeps/internal-lints/must_match_exhaustively.stderr b/tests/ui-fulldeps/internal-lints/must_match_exhaustively.stderr index b5db25cf0e06a..a145253e9faf5 100644 --- a/tests/ui-fulldeps/internal-lints/must_match_exhaustively.stderr +++ b/tests/ui-fulldeps/internal-lints/must_match_exhaustively.stderr @@ -1,7 +1,7 @@ error: match is not exhaustive - --> $DIR/must_match_exhaustively.rs:21:11 + --> $DIR/must_match_exhaustively.rs:24:11 | -LL | #[rustc_must_match_exhaustively] +LL | #[lint::must_match_exhaustively] | -------------------------------- required because of this attribute ... LL | match f { @@ -9,20 +9,20 @@ LL | match f { | = help: explicitly list all variants of the enum in a `match` note: because of this wildcard pattern - --> $DIR/must_match_exhaustively.rs:24:9 + --> $DIR/must_match_exhaustively.rs:27:9 | LL | _ => {} | ^ note: the lint level is defined here - --> $DIR/must_match_exhaustively.rs:6:9 + --> $DIR/must_match_exhaustively.rs:9:9 | -LL | #![deny(rustc::rustc_must_match_exhaustively)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(rustc::must_match_exhaustively)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: match is not exhaustive - --> $DIR/must_match_exhaustively.rs:27:11 + --> $DIR/must_match_exhaustively.rs:30:11 | -LL | #[rustc_must_match_exhaustively] +LL | #[lint::must_match_exhaustively] | -------------------------------- required because of this attribute ... LL | match f { @@ -30,15 +30,15 @@ LL | match f { | = help: explicitly list all variants of the enum in a `match` note: because of this variable binding - --> $DIR/must_match_exhaustively.rs:30:9 + --> $DIR/must_match_exhaustively.rs:33:9 | LL | a => {} | ^ error: match is not exhaustive - --> $DIR/must_match_exhaustively.rs:33:11 + --> $DIR/must_match_exhaustively.rs:36:11 | -LL | #[rustc_must_match_exhaustively] +LL | #[lint::must_match_exhaustively] | -------------------------------- required because of this attribute ... LL | match &f { @@ -46,15 +46,15 @@ LL | match &f { | = help: explicitly list all variants of the enum in a `match` note: because of this variable binding - --> $DIR/must_match_exhaustively.rs:36:9 + --> $DIR/must_match_exhaustively.rs:39:9 | LL | a => {} | ^ error: match is not exhaustive - --> $DIR/must_match_exhaustively.rs:44:8 + --> $DIR/must_match_exhaustively.rs:47:8 | -LL | #[rustc_must_match_exhaustively] +LL | #[lint::must_match_exhaustively] | -------------------------------- required because of this attribute ... LL | if let Foo::A { .. } = f {} @@ -62,15 +62,15 @@ LL | if let Foo::A { .. } = f {} | = help: explicitly list all variants of the enum in a `match` note: using `if let` only matches on one variant (try using `match`) - --> $DIR/must_match_exhaustively.rs:44:8 + --> $DIR/must_match_exhaustively.rs:47:8 | LL | if let Foo::A { .. } = f {} | ^^^^^^^^^^^^^^^^^^^^^ error: match is not exhaustive - --> $DIR/must_match_exhaustively.rs:47:5 + --> $DIR/must_match_exhaustively.rs:50:5 | -LL | #[rustc_must_match_exhaustively] +LL | #[lint::must_match_exhaustively] | -------------------------------- required because of this attribute ... LL | let Foo::A { .. } = f else { loop {} }; @@ -78,15 +78,15 @@ LL | let Foo::A { .. } = f else { loop {} }; | = help: explicitly list all variants of the enum in a `match` note: using `let else` only matches on one variant (try using `match`) - --> $DIR/must_match_exhaustively.rs:47:9 + --> $DIR/must_match_exhaustively.rs:50:9 | LL | let Foo::A { .. } = f else { loop {} }; | ^^^^^^^^^^^^^ error: match is not exhaustive - --> $DIR/must_match_exhaustively.rs:50:14 + --> $DIR/must_match_exhaustively.rs:53:14 | -LL | #[rustc_must_match_exhaustively] +LL | #[lint::must_match_exhaustively] | -------------------------------- required because of this attribute ... LL | matches!(f, Foo::A { .. }); @@ -94,7 +94,7 @@ LL | matches!(f, Foo::A { .. }); | = help: explicitly list all variants of the enum in a `match` note: because of this wildcard pattern - --> $DIR/must_match_exhaustively.rs:50:5 + --> $DIR/must_match_exhaustively.rs:53:5 | LL | matches!(f, Foo::A { .. }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.rs b/tests/ui/internal-lints/disallowed_pass_by_ref_self.rs similarity index 88% rename from tests/ui/internal-lints/rustc_pass_by_value_self.rs rename to tests/ui/internal-lints/disallowed_pass_by_ref_self.rs index 695c617d32f82..8452c7a4f1bfd 100644 --- a/tests/ui/internal-lints/rustc_pass_by_value_self.rs +++ b/tests/ui/internal-lints/disallowed_pass_by_ref_self.rs @@ -5,10 +5,12 @@ // Considering that all other `internal-lints` are tested here // this seems like the cleaner solution though. #![feature(rustc_attrs)] +#![feature(register_tool)] +#![register_tool(lint)] #![deny(rustc::disallowed_pass_by_ref)] #![allow(unused)] -#[rustc_pass_by_value] +#[lint::pass_by_value] struct TyCtxt<'tcx> { inner: &'tcx (), } @@ -22,7 +24,7 @@ struct TyS<'tcx> { inner: &'tcx (), } -#[rustc_pass_by_value] +#[lint::pass_by_value] type Ty<'tcx> = &'tcx TyS<'tcx>; impl<'tcx> TyS<'tcx> { @@ -30,14 +32,14 @@ impl<'tcx> TyS<'tcx> { fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference } -#[rustc_pass_by_value] +#[lint::pass_by_value] struct Foo; impl Foo { fn with_ref(&self) {} //~ ERROR passing `Foo` by reference } -#[rustc_pass_by_value] +#[lint::pass_by_value] struct WithParameters { slice: [T; N], m: M, diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.stderr b/tests/ui/internal-lints/disallowed_pass_by_ref_self.stderr similarity index 76% rename from tests/ui/internal-lints/rustc_pass_by_value_self.stderr rename to tests/ui/internal-lints/disallowed_pass_by_ref_self.stderr index d9e9f7e48506b..088849afa8067 100644 --- a/tests/ui/internal-lints/rustc_pass_by_value_self.stderr +++ b/tests/ui/internal-lints/disallowed_pass_by_ref_self.stderr @@ -1,35 +1,35 @@ error: passing `TyCtxt<'tcx>` by reference - --> $DIR/rustc_pass_by_value_self.rs:18:15 + --> $DIR/disallowed_pass_by_ref_self.rs:20:15 | LL | fn by_ref(&self) {} | ^^^^^ help: try passing by value: `TyCtxt<'tcx>` | note: the lint level is defined here - --> $DIR/rustc_pass_by_value_self.rs:8:9 + --> $DIR/disallowed_pass_by_ref_self.rs:10:9 | LL | #![deny(rustc::disallowed_pass_by_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: passing `Ty<'tcx>` by reference - --> $DIR/rustc_pass_by_value_self.rs:30:21 + --> $DIR/disallowed_pass_by_ref_self.rs:32:21 | LL | fn by_ref(self: &Ty<'tcx>) {} | ^^^^^^^^^ help: try passing by value: `Ty<'tcx>` error: passing `Foo` by reference - --> $DIR/rustc_pass_by_value_self.rs:37:17 + --> $DIR/disallowed_pass_by_ref_self.rs:39:17 | LL | fn with_ref(&self) {} | ^^^^^ help: try passing by value: `Foo` error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value_self.rs:47:17 + --> $DIR/disallowed_pass_by_ref_self.rs:49:17 | LL | fn with_ref(&self) {} | ^^^^^ help: try passing by value: `WithParameters` error: passing `WithParameters` by reference - --> $DIR/rustc_pass_by_value_self.rs:51:17 + --> $DIR/disallowed_pass_by_ref_self.rs:53:17 | LL | fn with_ref(&self) {} | ^^^^^ help: try passing by value: `WithParameters` diff --git a/tests/ui/lint/const-n-is-zero.rs b/tests/ui/lint/const-n-is-zero.rs index bb01a4c8eee55..a0e355e2fdc55 100644 --- a/tests/ui/lint/const-n-is-zero.rs +++ b/tests/ui/lint/const-n-is-zero.rs @@ -1,4 +1,4 @@ -// Test that core functions annotated with `#[rustc_panics_when_zero]` lint when `N` is zero +// Test that core functions annotated with `#[lint::panics_when_zero]` lint when `N` is zero //@ build-fail diff --git a/tests/ui/lint/improper-ctypes/unsafe-binder-basic.rs b/tests/ui/lint/improper-ctypes/unsafe-binder-basic.rs index 5d4279fc834d1..72070a0c6f89f 100644 --- a/tests/ui/lint/improper-ctypes/unsafe-binder-basic.rs +++ b/tests/ui/lint/improper-ctypes/unsafe-binder-basic.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] #![expect(incomplete_features)] #![deny(improper_ctypes)] diff --git a/tests/ui/lint/improper-ctypes/unsafe-binder-basic.stderr b/tests/ui/lint/improper-ctypes/unsafe-binder-basic.stderr index 4b8d51690f1a0..fcebae5724acf 100644 --- a/tests/ui/lint/improper-ctypes/unsafe-binder-basic.stderr +++ b/tests/ui/lint/improper-ctypes/unsafe-binder-basic.stderr @@ -1,12 +1,12 @@ error: `extern` block uses type `unsafe<'a> &'a ()`, which is not FFI-safe - --> $DIR/unsafe-binder-basic.rs:6:18 + --> $DIR/unsafe-binder-basic.rs:8:18 | LL | fn exit_2(x: unsafe<'a> &'a ()); | ^^^^^^^^^^^^^^^^^ not FFI-safe | = note: unsafe binders are incompatible with foreign function interfaces note: the lint level is defined here - --> $DIR/unsafe-binder-basic.rs:3:9 + --> $DIR/unsafe-binder-basic.rs:5:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmutability/unsafe-binder-opaque-type-layout.rs b/tests/ui/transmutability/unsafe-binder-opaque-type-layout.rs index e456e88e4a383..747bb0b13b5d2 100644 --- a/tests/ui/transmutability/unsafe-binder-opaque-type-layout.rs +++ b/tests/ui/transmutability/unsafe-binder-opaque-type-layout.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + //! Regression test for https://github.com/rust-lang/rust/issues/141400. #![feature(unsafe_binders)] diff --git a/tests/ui/transmutability/unsafe-binder-opaque-type-layout.stderr b/tests/ui/transmutability/unsafe-binder-opaque-type-layout.stderr index d2bfbfbf3a095..c3d886c63fdac 100644 --- a/tests/ui/transmutability/unsafe-binder-opaque-type-layout.stderr +++ b/tests/ui/transmutability/unsafe-binder-opaque-type-layout.stderr @@ -1,11 +1,20 @@ -error[E0277]: the trait bound `OpaqueType::{opaque#0}: Copy` is not satisfied - --> $DIR/unsafe-binder-opaque-type-layout.rs:9:19 +error[E0277]: the trait bound `OpaqueType::{opaque#0}: Copy` is not satisfied in `OpaqueType::{opaque#0}` + --> $DIR/unsafe-binder-opaque-type-layout.rs:11:19 | LL | type OpaqueType = unsafe<> impl OpaqueTrait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `OpaqueType::{opaque#0}` + | ^^^^^^^^^---------------- + | | | + | | within this `OpaqueType::{opaque#0}` + | within `OpaqueType::{opaque#0}`, the trait `Copy` is not implemented for `OpaqueType::{opaque#0}` + | +note: required because it appears within the type `OpaqueType::{opaque#0}` + --> $DIR/unsafe-binder-opaque-type-layout.rs:11:28 + | +LL | type OpaqueType = unsafe<> impl OpaqueTrait; + | ^^^^^^^^^^^^^^^^ error[E0119]: conflicting implementations of trait `AnotherTrait` for type `unsafe<> _` - --> $DIR/unsafe-binder-opaque-type-layout.rs:14:1 + --> $DIR/unsafe-binder-opaque-type-layout.rs:16:1 | LL | impl> AnotherTrait for T {} | ------------------------------------------------------- first implementation here @@ -13,7 +22,7 @@ LL | impl AnotherTrait for OpaqueType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `unsafe<> _` error: unconstrained opaque type - --> $DIR/unsafe-binder-opaque-type-layout.rs:9:28 + --> $DIR/unsafe-binder-opaque-type-layout.rs:11:28 | LL | type OpaqueType = unsafe<> impl OpaqueTrait; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unsafe-binders/binder-sized-crit.rs b/tests/ui/unsafe-binders/binder-sized-crit.rs index cda807119ef9b..7e218a29d29be 100644 --- a/tests/ui/unsafe-binders/binder-sized-crit.rs +++ b/tests/ui/unsafe-binders/binder-sized-crit.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ check-pass #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/cat-projection.rs b/tests/ui/unsafe-binders/cat-projection.rs index 0ce8579a68827..2b20a65392f04 100644 --- a/tests/ui/unsafe-binders/cat-projection.rs +++ b/tests/ui/unsafe-binders/cat-projection.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ revisions: e2015 e2021 //@[e2015] edition: 2015 //@[e2021] edition: 2021 diff --git a/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs b/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs index 269eecf0df0cd..55e798304d447 100644 --- a/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs +++ b/tests/ui/unsafe-binders/debuginfo-escaping-bound-vars-issue-159576.rs @@ -1,4 +1,5 @@ //@ check-pass +//@ compile-flags: -Znext-solver //@ compile-flags: --crate-type=lib -Cdebuginfo=2 #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/discriminant-for-variant.rs b/tests/ui/unsafe-binders/discriminant-for-variant.rs index 6a2ef22e92628..783c566e4aa42 100644 --- a/tests/ui/unsafe-binders/discriminant-for-variant.rs +++ b/tests/ui/unsafe-binders/discriminant-for-variant.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] const None: Option Option>> = None; diff --git a/tests/ui/unsafe-binders/discriminant-for-variant.stderr b/tests/ui/unsafe-binders/discriminant-for-variant.stderr index ed1a38ae14e40..44cc84070e414 100644 --- a/tests/ui/unsafe-binders/discriminant-for-variant.stderr +++ b/tests/ui/unsafe-binders/discriminant-for-variant.stderr @@ -1,18 +1,22 @@ error[E0277]: the trait bound `Box<(dyn Send + 'static)>: Copy` is not satisfied - --> $DIR/discriminant-for-variant.rs:3:13 + --> $DIR/discriminant-for-variant.rs:5:13 | LL | const None: Option Option>> = None; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Box<(dyn Send + 'static)>` | = note: required for `Option>` to implement `Copy` +note: required because it appears within the type `Option>` + --> $SRC_DIR/core/src/option.rs:LL:COL error[E0277]: the trait bound `Box<(dyn Send + 'static)>: Copy` is not satisfied - --> $DIR/discriminant-for-variant.rs:3:54 + --> $DIR/discriminant-for-variant.rs:5:54 | LL | const None: Option Option>> = None; | ^^^^ the trait `Copy` is not implemented for `Box<(dyn Send + 'static)>` | = note: required for `Option>` to implement `Copy` +note: required because it appears within the type `Option>` + --> $SRC_DIR/core/src/option.rs:LL:COL error: aborting due to 2 previous errors diff --git a/tests/ui/unsafe-binders/expr.rs b/tests/ui/unsafe-binders/expr.rs index 9feb29439187d..413ae6dd853e7 100644 --- a/tests/ui/unsafe-binders/expr.rs +++ b/tests/ui/unsafe-binders/expr.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ check-pass #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/layout-invariant.rs b/tests/ui/unsafe-binders/layout-invariant.rs index 46fb2e2839eae..ff5febe51903b 100644 --- a/tests/ui/unsafe-binders/layout-invariant.rs +++ b/tests/ui/unsafe-binders/layout-invariant.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + // Regression test for https://github.com/rust-lang/rust/issues/154426 #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/layout-invariant.stderr b/tests/ui/unsafe-binders/layout-invariant.stderr index 8eb00897c8520..b34535ce19cf2 100644 --- a/tests/ui/unsafe-binders/layout-invariant.stderr +++ b/tests/ui/unsafe-binders/layout-invariant.stderr @@ -1,18 +1,22 @@ error[E0277]: the trait bound `unsafe<'a> Adt<'a>: Copy` is not satisfied - --> $DIR/layout-invariant.rs:9:13 + --> $DIR/layout-invariant.rs:11:13 | LL | const None: Option Option Adt<'a>>> = None; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `unsafe<'a> Adt<'a>` | = note: required for `Option Adt<'a>>` to implement `Copy` +note: required because it appears within the type `Option Adt<'a>>` + --> $SRC_DIR/core/src/option.rs:LL:COL error[E0277]: the trait bound `unsafe<'a> Adt<'a>: Copy` is not satisfied - --> $DIR/layout-invariant.rs:9:59 + --> $DIR/layout-invariant.rs:11:59 | LL | const None: Option Option Adt<'a>>> = None; | ^^^^ the trait `Copy` is not implemented for `unsafe<'a> Adt<'a>` | = note: required for `Option Adt<'a>>` to implement `Copy` +note: required because it appears within the type `Option Adt<'a>>` + --> $SRC_DIR/core/src/option.rs:LL:COL error: aborting due to 2 previous errors diff --git a/tests/ui/unsafe-binders/lifetime-resolution.rs b/tests/ui/unsafe-binders/lifetime-resolution.rs index 9935edffaa53f..c70df9028066c 100644 --- a/tests/ui/unsafe-binders/lifetime-resolution.rs +++ b/tests/ui/unsafe-binders/lifetime-resolution.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] fn foo<'a>() { diff --git a/tests/ui/unsafe-binders/lifetime-resolution.stderr b/tests/ui/unsafe-binders/lifetime-resolution.stderr index 2f445e9a02b46..7b4bcea0c903c 100644 --- a/tests/ui/unsafe-binders/lifetime-resolution.stderr +++ b/tests/ui/unsafe-binders/lifetime-resolution.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'missing` - --> $DIR/lifetime-resolution.rs:6:28 + --> $DIR/lifetime-resolution.rs:8:28 | LL | let missing: unsafe<> &'missing (); | ^^^^^^^^ undeclared lifetime @@ -15,7 +15,7 @@ LL | fn foo<'missing, 'a>() { | +++++++++ error[E0401]: can't use generic parameters from outer item - --> $DIR/lifetime-resolution.rs:10:30 + --> $DIR/lifetime-resolution.rs:12:30 | LL | fn foo<'a>() { | -- lifetime parameter from outer item diff --git a/tests/ui/unsafe-binders/mismatch.rs b/tests/ui/unsafe-binders/mismatch.rs index 8da94ccebb73f..b834b686f8908 100644 --- a/tests/ui/unsafe-binders/mismatch.rs +++ b/tests/ui/unsafe-binders/mismatch.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] use std::unsafe_binder::{wrap_binder, unwrap_binder}; diff --git a/tests/ui/unsafe-binders/mismatch.stderr b/tests/ui/unsafe-binders/mismatch.stderr index f0a8854c71919..e843c351cc6d0 100644 --- a/tests/ui/unsafe-binders/mismatch.stderr +++ b/tests/ui/unsafe-binders/mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mismatch.rs:6:46 + --> $DIR/mismatch.rs:8:46 | LL | let _: unsafe<'a> &'a i32 = wrap_binder!(&()); | ^^^ expected `&i32`, found `&()` @@ -8,7 +8,7 @@ LL | let _: unsafe<'a> &'a i32 = wrap_binder!(&()); found reference `&()` error: `wrap_binder!()` can only wrap into unsafe binder, not `i32` - --> $DIR/mismatch.rs:11:18 + --> $DIR/mismatch.rs:13:18 | LL | let _: i32 = wrap_binder!(&()); | ^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let _: i32 = wrap_binder!(&()); = note: unsafe binders are the only valid output of wrap error: expected unsafe binder, found integer as input of `unwrap_binder!()` - --> $DIR/mismatch.rs:17:20 + --> $DIR/mismatch.rs:19:20 | LL | unwrap_binder!(y); | ^ @@ -24,7 +24,7 @@ LL | unwrap_binder!(y); = note: only an unsafe binder type can be unwrapped error[E0282]: type annotations needed - --> $DIR/mismatch.rs:22:9 + --> $DIR/mismatch.rs:24:9 | LL | let unknown = Default::default(); | ^^^^^^^ @@ -38,7 +38,7 @@ LL | let unknown: /* Type */ = Default::default(); | ++++++++++++ error[E0282]: type annotations needed - --> $DIR/mismatch.rs:28:26 + --> $DIR/mismatch.rs:30:26 | LL | let x = wrap_binder!(&42); | ^^^ cannot infer type diff --git a/tests/ui/unsafe-binders/move-out-of-non-copy.rs b/tests/ui/unsafe-binders/move-out-of-non-copy.rs index ca6bf4277a152..b7eefb97a758d 100644 --- a/tests/ui/unsafe-binders/move-out-of-non-copy.rs +++ b/tests/ui/unsafe-binders/move-out-of-non-copy.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ compile-flags: -Zvalidate-mir // Regression test for . diff --git a/tests/ui/unsafe-binders/move-out-of-non-copy.stderr b/tests/ui/unsafe-binders/move-out-of-non-copy.stderr index 4598742c92b43..cbaf93821b4d3 100644 --- a/tests/ui/unsafe-binders/move-out-of-non-copy.stderr +++ b/tests/ui/unsafe-binders/move-out-of-non-copy.stderr @@ -1,9 +1,10 @@ -error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/move-out-of-non-copy.rs:10:13 +error[E0277]: the trait bound `T: Copy` is not satisfied in `T` + --> $DIR/move-out-of-non-copy.rs:11:13 | LL | fn id(x: unsafe<> T) -> T { - | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` + | ^^^^^^^^^^ within `T`, the trait `Copy` is not implemented for `T` | + = note: required because it appears within the type `T` help: consider restricting type parameter `T` with trait `Copy` | LL | fn id(x: unsafe<> T) -> T { diff --git a/tests/ui/unsafe-binders/moves.rs b/tests/ui/unsafe-binders/moves.rs index df2cb2265e663..543f684f072d9 100644 --- a/tests/ui/unsafe-binders/moves.rs +++ b/tests/ui/unsafe-binders/moves.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] use std::mem::{ManuallyDrop, drop}; diff --git a/tests/ui/unsafe-binders/moves.stderr b/tests/ui/unsafe-binders/moves.stderr index 18f63a4d1de3a..5b53f1f721ddf 100644 --- a/tests/ui/unsafe-binders/moves.stderr +++ b/tests/ui/unsafe-binders/moves.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `base` - --> $DIR/moves.rs:14:14 + --> $DIR/moves.rs:16:14 | LL | let base = NotCopy::default(); | ---- move occurs because `base` has type `ManuallyDrop`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | drop(base); | ^^^^ value used here after move | note: if `NotCopyInner` implemented `Clone`, you could clone the value - --> $DIR/moves.rs:7:1 + --> $DIR/moves.rs:9:1 | LL | struct NotCopyInner; | ^^^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type @@ -18,7 +18,7 @@ LL | let binder: unsafe<> NotCopy = wrap_binder!(base); | ---- you could clone this value error[E0382]: use of moved value: `binder` - --> $DIR/moves.rs:23:14 + --> $DIR/moves.rs:25:14 | LL | drop(unwrap_binder!(binder)); | ---------------------- value moved here @@ -28,7 +28,7 @@ LL | drop(unwrap_binder!(binder)); = note: move occurs because `binder` has type `ManuallyDrop`, which does not implement the `Copy` trait error[E0382]: use of moved value: `binder.0` - --> $DIR/moves.rs:35:14 + --> $DIR/moves.rs:37:14 | LL | drop(unwrap_binder!(binder).0); | ------------------------ value moved here diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.rs b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs index e021e9567e5c8..ba7ed163eb02a 100644 --- a/tests/ui/unsafe-binders/non-strucutral-type-diag.rs +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + // regression test for . #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr index ab23210b2e577..d9a78b84ffe18 100644 --- a/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr @@ -1,5 +1,5 @@ error: constant of non-structural type `Option<(unsafe<'a> Adt<'a>, Box)>` in a pattern - --> $DIR/non-strucutral-type-diag.rs:13:9 + --> $DIR/non-strucutral-type-diag.rs:15:9 | LL | const C: Option<(unsafe<'a> Adt<'a>, Box)> = None; | ---------------------------------------------------- constant defined here diff --git a/tests/ui/unsafe-binders/simple.rs b/tests/ui/unsafe-binders/simple.rs index 99f20d6b2ec96..ac14138906d87 100644 --- a/tests/ui/unsafe-binders/simple.rs +++ b/tests/ui/unsafe-binders/simple.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Znext-solver //@ check-pass #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/type-mismatch.rs b/tests/ui/unsafe-binders/type-mismatch.rs index 22937bb09e827..73cea0a071c4f 100644 --- a/tests/ui/unsafe-binders/type-mismatch.rs +++ b/tests/ui/unsafe-binders/type-mismatch.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Znext-solver + #![feature(unsafe_binders)] fn main() { diff --git a/tests/ui/unsafe-binders/type-mismatch.stderr b/tests/ui/unsafe-binders/type-mismatch.stderr index 6262620ff6b0a..6ba82fcd7a770 100644 --- a/tests/ui/unsafe-binders/type-mismatch.stderr +++ b/tests/ui/unsafe-binders/type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:4:27 + --> $DIR/type-mismatch.rs:6:27 | LL | let x: unsafe<> i32 = 0; | ------------ ^ expected `unsafe<> i32`, found integer @@ -10,7 +10,7 @@ LL | let x: unsafe<> i32 = 0; found type `{integer}` error[E0308]: mismatched types - --> $DIR/type-mismatch.rs:6:33 + --> $DIR/type-mismatch.rs:8:33 | LL | let x: unsafe<'a> &'a i32 = &0; | ------------------ ^^ expected `unsafe<'a> &i32`, found `&{integer}` diff --git a/tests/ui/unsafe-binders/unsafe-binders-debuginfo.rs b/tests/ui/unsafe-binders/unsafe-binders-debuginfo.rs index f0f1a6f99b9e9..3beee414973e1 100644 --- a/tests/ui/unsafe-binders/unsafe-binders-debuginfo.rs +++ b/tests/ui/unsafe-binders/unsafe-binders-debuginfo.rs @@ -1,5 +1,6 @@ // This is a regression test for . //@ check-pass +//@ compile-flags: -Znext-solver //@ compile-flags: -Cdebuginfo=2 #![feature(unsafe_binders)] diff --git a/tests/ui/unsafe-binders/unused-lifetimes-2.fixed b/tests/ui/unsafe-binders/unused-lifetimes-2.fixed index 714a5fdaf0311..7352cee731776 100644 --- a/tests/ui/unsafe-binders/unused-lifetimes-2.fixed +++ b/tests/ui/unsafe-binders/unused-lifetimes-2.fixed @@ -1,4 +1,5 @@ // regression test for #141758 +//@ compile-flags: -Znext-solver //@ run-rustfix //@ check-pass diff --git a/tests/ui/unsafe-binders/unused-lifetimes-2.rs b/tests/ui/unsafe-binders/unused-lifetimes-2.rs index 5b34cf911637a..04e36b4252e00 100644 --- a/tests/ui/unsafe-binders/unused-lifetimes-2.rs +++ b/tests/ui/unsafe-binders/unused-lifetimes-2.rs @@ -1,4 +1,5 @@ // regression test for #141758 +//@ compile-flags: -Znext-solver //@ run-rustfix //@ check-pass diff --git a/tests/ui/unsafe-binders/unused-lifetimes-2.stderr b/tests/ui/unsafe-binders/unused-lifetimes-2.stderr index bca8a15d56bd6..42df1ba2793dc 100644 --- a/tests/ui/unsafe-binders/unused-lifetimes-2.stderr +++ b/tests/ui/unsafe-binders/unused-lifetimes-2.stderr @@ -1,5 +1,5 @@ warning: lifetime parameter `'b` never used - --> $DIR/unused-lifetimes-2.rs:15:32 + --> $DIR/unused-lifetimes-2.rs:16:32 | LL | pub fn by_value(_x: unsafe<'a, 'b> &'a S) -> usize { | --^^ @@ -7,7 +7,7 @@ LL | pub fn by_value(_x: unsafe<'a, 'b> &'a S) -> usize { | help: elide the unused lifetime | note: the lint level is defined here - --> $DIR/unused-lifetimes-2.rs:5:9 + --> $DIR/unused-lifetimes-2.rs:6:9 | LL | #![warn(unused_lifetimes)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unsafe-binders/unused-lifetimes.fixed b/tests/ui/unsafe-binders/unused-lifetimes.fixed index 4295b6a848c37..e7fdaf96b98fc 100644 --- a/tests/ui/unsafe-binders/unused-lifetimes.fixed +++ b/tests/ui/unsafe-binders/unused-lifetimes.fixed @@ -1,4 +1,5 @@ // regression test for #141758 +//@ compile-flags: -Znext-solver //@ run-rustfix //@ check-pass diff --git a/tests/ui/unsafe-binders/unused-lifetimes.rs b/tests/ui/unsafe-binders/unused-lifetimes.rs index b13823283183d..a27ad61e5c9ec 100644 --- a/tests/ui/unsafe-binders/unused-lifetimes.rs +++ b/tests/ui/unsafe-binders/unused-lifetimes.rs @@ -1,4 +1,5 @@ // regression test for #141758 +//@ compile-flags: -Znext-solver //@ run-rustfix //@ check-pass diff --git a/tests/ui/unsafe-binders/unused-lifetimes.stderr b/tests/ui/unsafe-binders/unused-lifetimes.stderr index d9a5216301f50..3b4a70c73e18b 100644 --- a/tests/ui/unsafe-binders/unused-lifetimes.stderr +++ b/tests/ui/unsafe-binders/unused-lifetimes.stderr @@ -1,11 +1,11 @@ warning: lifetime parameter `'a` never used - --> $DIR/unused-lifetimes.rs:15:28 + --> $DIR/unused-lifetimes.rs:16:28 | LL | pub fn by_value(_x: unsafe<'a> S) -> usize { | -------^^-- help: elide the unused lifetime | note: the lint level is defined here - --> $DIR/unused-lifetimes.rs:5:9 + --> $DIR/unused-lifetimes.rs:6:9 | LL | #![warn(unused_lifetimes)] | ^^^^^^^^^^^^^^^^