diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs b/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs index 8006c3c766ced..04caf0a60be71 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs @@ -526,7 +526,6 @@ impl InitMaskMaterialized { None } - #[cfg_attr(not(debug_assertions), allow(dead_code))] fn find_bit_slow( init_mask: &InitMaskMaterialized, start: Size, diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs index 4cb577ebed8e7..7e8483d6ed877 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs @@ -290,7 +290,6 @@ impl ProvenanceMap { } /// Removes all provenance inside the given range. - #[allow(irrefutable_let_patterns)] // these actually make the code more clear pub fn clear(&mut self, range: AllocRange, data_bytes: &[u8], cx: &impl HasDataLayout) { if range.size == Size::ZERO { return; diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 56f6ac4368d5f..429ab7d928fc5 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -1083,7 +1083,6 @@ macro_rules! super_body { $self.visit_local_decl(local, & $($mutability)? $body.local_decls[local]); } - #[allow(unused_macro_rules)] macro_rules! type_annotations { (mut) => ($body.user_type_annotations.iter_enumerated_mut()); () => ($body.user_type_annotations.iter_enumerated()); diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index b19a54ff52eb5..ef640f5e996d9 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -43,8 +43,6 @@ //! //! For more details, see the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/query.html). -#![allow(unused_parens)] - use std::ffi::OsStr; use std::path::PathBuf; use std::sync::Arc; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 4ae165cb015bd..2cd6037969318 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1736,9 +1736,7 @@ nop_list_lift! { args; GenericArg<'a> => GenericArg<'tcx> } macro_rules! sty_debug_print { ($fmt: expr, $ctxt: expr, $($variant: ident),*) => {{ - // Curious inner module to allow variant names to be used as - // variable names. - #[allow(non_snake_case)] + #[allow(non_snake_case, reason = "we're using variant names as local variables")] mod inner { use crate::ty::{self, TyCtxt}; use crate::ty::context::InternedInSet; diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 151ca10b85ef6..4a34f8d5923d6 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -57,17 +57,9 @@ use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol}; use rustc_target::callconv::FnAbi; pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet}; pub use rustc_type_ir::fast_reject::DeepRejectCtxt; -#[allow( - hidden_glob_reexports, - rustc::usage_of_type_ir_inherent, - rustc::non_glob_import_of_type_ir_inherent -)] -use rustc_type_ir::inherent; pub use rustc_type_ir::relate::VarianceDiagInfo; pub use rustc_type_ir::solve::{CandidatePreferenceMode, SizedTraitKind, VisibleForLeakCheck}; pub use rustc_type_ir::*; -#[allow(hidden_glob_reexports, unused_imports)] -use rustc_type_ir::{InferCtxtLike, Interner}; use tracing::{debug, instrument}; pub use vtable::*; @@ -170,7 +162,7 @@ mod opaque_types; mod predicate; mod region; mod structural_impls; -#[allow(hidden_glob_reexports)] +#[expect(hidden_glob_reexports)] mod sty; mod typeck_results; mod visit; @@ -1936,7 +1928,7 @@ impl<'tcx> TyCtxt<'tcx> { did: impl Into, attr: Symbol, ) -> impl Iterator { - #[allow(deprecated)] + #[expect(deprecated)] self.get_all_attrs(did).iter().filter(move |a: &&hir::Attribute| a.has_name(attr)) } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3614a67b71045..4ff8778d8c2a4 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -3126,18 +3126,20 @@ pub struct PrintClosureAsImpl<'tcx> { macro_rules! forward_display_to_print { ($($ty:ty),+) => { - // Some of the $ty arguments may not actually use 'tcx - $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - ty::tls::with(|tcx| { - let mut p = FmtPrinter::new(tcx, Namespace::TypeNS); - tcx.lift(*self) - .print(&mut p)?; - f.write_str(&p.into_buffer())?; - Ok(()) - }) + $( + #[allow(unused_lifetimes, reason = "not all `$ty` have a 'tcx")] + impl<'tcx> fmt::Display for $ty { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + ty::tls::with(|tcx| { + let mut p = FmtPrinter::new(tcx, Namespace::TypeNS); + tcx.lift(*self) + .print(&mut p)?; + f.write_str(&p.into_buffer())?; + Ok(()) + }) + } } - })+ + )+ }; } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index ff787c0ede7f7..6789d3de52e19 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -369,7 +369,6 @@ impl ParamConst { impl<'tcx> Ty<'tcx> { /// Avoid using this in favour of more specific `new_*` methods, where possible. /// The more specific methods will often optimize their creation. - #[allow(rustc::usage_of_ty_tykind)] #[inline] fn new(tcx: TyCtxt<'tcx>, st: TyKind<'tcx>) -> Ty<'tcx> { tcx.mk_ty_from_kind(st) diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 919bc3cdcc3d9..02f7bbbfe66de 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -15,11 +15,11 @@ pub mod outlives_bounds; pub mod outlives_for_liveness; pub mod project; pub mod query; -#[allow(hidden_glob_reexports)] +#[expect(hidden_glob_reexports)] mod select; pub mod specialize; mod structural_normalize; -#[allow(hidden_glob_reexports)] +#[expect(hidden_glob_reexports)] mod util; pub mod vtable; pub mod wf;