diff --git a/Cargo.lock b/Cargo.lock index 6afbc7d22f098..cfed18eee113c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1665,7 +1665,6 @@ dependencies = [ "allocator-api2", "equivalent", "foldhash 0.1.5", - "serde", ] [[package]] @@ -1675,6 +1674,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "foldhash 0.2.0", + "serde", + "serde_core", ] [[package]] @@ -1898,9 +1899,9 @@ dependencies = [ [[package]] name = "id-arena" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" [[package]] name = "ident_case" @@ -6152,9 +6153,9 @@ dependencies = [ [[package]] name = "wasm-component-ld" -version = "0.5.20" +version = "0.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "846d20ed66ae37b7a237e36dfcd2fdc979eae82a46cdb0586f9bba80782fd789" +checksum = "59dcd765f510df84d1677a502c49057761486597a95950b4c92153e5707af091" dependencies = [ "anyhow", "clap", @@ -6163,7 +6164,7 @@ dependencies = [ "libc", "tempfile", "wasi-preview1-component-adapter-provider", - "wasmparser 0.243.0", + "wasmparser 0.245.1", "wat", "windows-sys 0.61.2", "winsplit", @@ -6190,24 +6191,24 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.243.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55db9c896d70bd9fa535ce83cd4e1f2ec3726b0edd2142079f594fc3be1cb35" +checksum = "3f9dca005e69bf015e45577e415b9af8c67e8ee3c0e38b5b0add5aa92581ed5c" dependencies = [ "leb128fmt", - "wasmparser 0.243.0", + "wasmparser 0.245.1", ] [[package]] name = "wasm-metadata" -version = "0.243.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae05bf9579f45a62e8d0a4e3f52eaa8da518883ac5afa482ec8256c329ecd56" +checksum = "da55e60097e8b37b475a0fa35c3420dd71d9eb7bd66109978ab55faf56a57efb" dependencies = [ "anyhow", "indexmap", - "wasm-encoder 0.243.0", - "wasmparser 0.243.0", + "wasm-encoder 0.245.1", + "wasmparser 0.245.1", ] [[package]] @@ -6232,12 +6233,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.243.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d" +checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e" dependencies = [ "bitflags", - "hashbrown 0.15.5", + "hashbrown 0.16.1", "indexmap", "semver", "serde", @@ -6245,22 +6246,22 @@ dependencies = [ [[package]] name = "wast" -version = "243.0.0" +version = "245.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df21d01c2d91e46cb7a221d79e58a2d210ea02020d57c092e79255cc2999ca7f" +checksum = "28cf1149285569120b8ce39db8b465e8a2b55c34cbb586bd977e43e2bc7300bf" dependencies = [ "bumpalo", "leb128fmt", "memchr", "unicode-width 0.2.2", - "wasm-encoder 0.243.0", + "wasm-encoder 0.245.1", ] [[package]] name = "wat" -version = "1.243.0" +version = "1.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226a9a91cd80a50449312fef0c75c23478fcecfcc4092bdebe1dc8e760ef521b" +checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be" dependencies = [ "wast", ] @@ -6707,9 +6708,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.243.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f9fc53513e461ce51dcf17a3e331752cb829f1d187069e54af5608fc998fe4" +checksum = "4894f10d2d5cbc17c77e91f86a1e48e191a788da4425293b55c98b44ba3fcac9" dependencies = [ "anyhow", "bitflags", @@ -6718,19 +6719,20 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "wasm-encoder 0.243.0", + "wasm-encoder 0.245.1", "wasm-metadata", - "wasmparser 0.243.0", + "wasmparser 0.245.1", "wit-parser", ] [[package]] name = "wit-parser" -version = "0.243.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df983a8608e513d8997f435bb74207bf0933d0e49ca97aa9d8a6157164b9b7fc" +checksum = "330698718e82983499419494dd1e3d7811a457a9bf9f69734e8c5f07a2547929" dependencies = [ "anyhow", + "hashbrown 0.16.1", "id-arena", "indexmap", "log", @@ -6739,7 +6741,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.243.0", + "wasmparser 0.245.1", ] [[package]] diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 88f8b7cc51704..2a783cd73d9de 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1036,6 +1036,19 @@ impl Align { // LLVM has a maximal supported alignment of 2^29, we inherit that. pub const MAX: Align = Align { pow2: 29 }; + /// Either `1 << (pointer_bits - 1)` or [`Align::MAX`], whichever is smaller. + #[inline] + pub fn max_for_target(tdl: &TargetDataLayout) -> Align { + let pointer_bits = tdl.pointer_size().bits(); + if let Ok(pointer_bits) = u8::try_from(pointer_bits) + && pointer_bits <= Align::MAX.pow2 + { + Align { pow2: pointer_bits - 1 } + } else { + Align::MAX + } + } + #[inline] pub fn from_bits(bits: u64) -> Result { Align::from_bytes(Size::from_bits(bits).bytes()) diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index b6e18240cbab1..738e3330254b7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -626,7 +626,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let predicates = match parent.kind { hir::ExprKind::Call(callee, _) => { let ty = typeck_result.node_type_opt(callee.hir_id)?; - let ty::FnDef(fn_def_id, args) = ty.kind() else { return None }; + let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None }; tcx.predicates_of(fn_def_id).instantiate(tcx, args) } hir::ExprKind::MethodCall(..) => { diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 824125099cfde..a0e53248c9047 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -614,7 +614,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } _ => { let local = &self.body.local_decls[local]; - match local.local_info() { + match *local.local_info() { LocalInfo::StaticRef { def_id, .. } => { let span = self.infcx.tcx.def_span(def_id); err.span_label(span, format!("this `static` cannot be {acted_on}")); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index a9c00660c3a20..a3738689ed05f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -926,7 +926,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let tcx = self.infcx.tcx; let ConstraintCategory::CallArgument(Some(func_ty)) = category else { return }; - let ty::FnDef(fn_did, args) = func_ty.kind() else { return }; + let ty::FnDef(fn_did, args) = *func_ty.kind() else { return }; debug!(?fn_did, ?args); // Only suggest this on function calls, not closures @@ -938,7 +938,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let Ok(Some(instance)) = ty::Instance::try_resolve( tcx, self.infcx.typing_env(self.infcx.param_env), - *fn_did, + fn_did, self.infcx.resolve_vars_if_possible(args), ) else { return; diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 2935559147b7e..29d38af472c22 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1013,12 +1013,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { let is_implicit_coercion = coercion_source == CoercionSource::Implicit; let src_ty = op.ty(self.body, tcx); let mut src_sig = src_ty.fn_sig(tcx); - if let ty::FnDef(def_id, _) = src_ty.kind() + if let ty::FnDef(def_id, _) = *src_ty.kind() && let ty::FnPtr(_, target_hdr) = *ty.kind() && tcx.codegen_fn_attrs(def_id).safe_target_features && target_hdr.safety.is_safe() && let Some(safe_sig) = tcx.adjust_target_feature_sig( - *def_id, + def_id, src_sig, self.body.source.def_id(), ) diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index f5ee9406f4bf1..fd0c7c656ac21 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -1,4 +1,4 @@ -use rustc_abi::WrappingRange; +use rustc_abi::{Align, WrappingRange}; use rustc_middle::mir::SourceInfo; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; @@ -179,9 +179,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128; bx.range_metadata(value, WrappingRange { start: 0, end: size_bound }); } - // Alignment is always nonzero. + // Alignment is always a power of two, thus 1..=0x800…000, + // but also bounded by the maximum we support in type layout. sym::vtable_align => { - bx.range_metadata(value, WrappingRange { start: 1, end: !0 }) + let align_bound = Align::max_for_target(bx.data_layout()).bytes().into(); + bx.range_metadata(value, WrappingRange { start: 1, end: align_bound }) } _ => {} } diff --git a/compiler/rustc_codegen_ssa/src/size_of_val.rs b/compiler/rustc_codegen_ssa/src/size_of_val.rs index e1bd8014d7a2f..52ffc321cbb6f 100644 --- a/compiler/rustc_codegen_ssa/src/size_of_val.rs +++ b/compiler/rustc_codegen_ssa/src/size_of_val.rs @@ -1,6 +1,6 @@ //! Computing the size and alignment of a value. -use rustc_abi::WrappingRange; +use rustc_abi::{Align, WrappingRange}; use rustc_hir::LangItem; use rustc_middle::bug; use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; @@ -36,8 +36,10 @@ pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // Size is always <= isize::MAX. let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128; bx.range_metadata(size, WrappingRange { start: 0, end: size_bound }); - // Alignment is always nonzero. - bx.range_metadata(align, WrappingRange { start: 1, end: !0 }); + // Alignment is always a power of two, thus 1..=0x800…000, + // but also bounded by the maximum we support in type layout. + let align_bound = Align::max_for_target(bx.data_layout()).bytes().into(); + bx.range_metadata(align, WrappingRange { start: 1, end: align_bound }); (size, align) } diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index e4f99be339df5..43a4c41eaeffc 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -577,7 +577,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { Rvalue::Aggregate(kind, ..) => { if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref() - && let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id) + && let Some(coroutine_kind) = self.tcx.coroutine_kind(*def_id) { self.check_op(ops::Coroutine(coroutine_kind)); } diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 04773ad3f8bc1..349ad4f7fc43b 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1221,7 +1221,7 @@ fn check_impl_items_against_trait<'tcx>( match impl_trait_header.polarity { ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {} ty::ImplPolarity::Negative => { - if let [first_item_ref, ..] = impl_item_refs { + if let [first_item_ref, ..] = *impl_item_refs { let first_item_span = tcx.def_span(first_item_ref); struct_span_code_err!( tcx.dcx(), diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index c29ebe67a158e..43a4f0574f5b0 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1333,7 +1333,7 @@ fn check_region_late_boundedness<'tcx>( .iter() .map(|param| { let (LateEarlyMismatch::EarlyInImpl(impl_param_def_id, ..) - | LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = param; + | LateEarlyMismatch::LateInImpl(impl_param_def_id, ..)) = *param; tcx.def_span(impl_param_def_id) }) .collect(); diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index ff919bd58ba16..18244d62f2ae6 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -2445,12 +2445,12 @@ fn is_late_bound_map( )) => { // See comments on `ConstrainedCollectorPostHirTyLowering` for why this arm does not // just consider args to be unconstrained. - let generics = self.tcx.generics_of(alias_def); + let generics = self.tcx.generics_of(*alias_def); let mut walker = ConstrainedCollectorPostHirTyLowering { arg_is_constrained: vec![false; generics.own_params.len()] .into_boxed_slice(), }; - walker.visit_ty(self.tcx.type_of(alias_def).instantiate_identity()); + walker.visit_ty(self.tcx.type_of(*alias_def).instantiate_identity()); match segments.last() { Some(hir::PathSegment { args: Some(args), .. }) => { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 2b23abce894c1..52e5cce140ad8 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -214,7 +214,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { if let [best_trait] = visible_traits .iter() .copied() - .filter(|trait_def_id| { + .filter(|&trait_def_id| { tcx.associated_items(trait_def_id) .filter_by_name_unhygienic(suggested_name) .any(|item| item.tag() == assoc_tag) @@ -1234,7 +1234,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { && let name = Symbol::intern(&format!("{ident2}_{ident3}")) && let Some(item) = inherent_impls .iter() - .flat_map(|inherent_impl| { + .flat_map(|&inherent_impl| { tcx.associated_items(inherent_impl).filter_by_name_unhygienic(name) }) .next() diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index f5c77c6800003..312b01d70f00e 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -101,7 +101,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained( let lifetimes_in_associated_types: FxHashSet<_> = tcx .associated_item_def_ids(impl_def_id) .iter() - .flat_map(|def_id| { + .flat_map(|&def_id| { let item = tcx.associated_item(def_id); match item.kind { ty::AssocKind::Type { .. } => { diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 471aa4384984a..04870bc85deb6 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef); } - match autoderef.final_ty().kind() { + match *autoderef.final_ty().kind() { ty::FnDef(def_id, _) => { let abi = self.tcx.fn_sig(def_id).skip_binder().skip_binder().abi; self.check_call_abi(abi, call_expr.span); @@ -98,6 +98,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => { /* cannot have a non-rust abi */ } } + if self.is_scalable_vector_ctor(autoderef.final_ty()) { + let mut err = self.dcx().create_err(errors::ScalableVectorCtor { + span: callee_expr.span, + ty: autoderef.final_ty(), + }); + err.span_label(callee_expr.span, "you can create scalable vectors using intrinsics"); + Ty::new_error(self.tcx, err.emit()); + } + self.register_predicates(autoderef.into_obligations()); let output = match result { @@ -420,6 +429,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None } + fn is_scalable_vector_ctor(&self, callee_ty: Ty<'_>) -> bool { + if let ty::FnDef(def_id, _) = callee_ty.kind() + && let def::DefKind::Ctor(def::CtorOf::Struct, _) = self.tcx.def_kind(def_id) + { + self.tcx + .opt_parent(*def_id) + .and_then(|id| self.tcx.adt_def(id).repr().scalable) + .is_some() + } else { + false + } + } + /// Give appropriate suggestion when encountering `||{/* not callable */}()`, where the /// likely intention is to call the closure, suggest `(||{})()`. (#55851) fn identify_bad_closure_def_and_call( diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 7e81abd1df293..5c44836adcd01 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -569,6 +569,14 @@ pub(crate) struct InvalidCallee<'tcx> { pub found: String, } +#[derive(Diagnostic)] +#[diag("scalable vector types cannot be initialised using their constructor")] +pub(crate) struct ScalableVectorCtor<'tcx> { + #[primary_span] + pub span: Span, + pub ty: Ty<'tcx>, +} + #[derive(Diagnostic)] #[diag("cannot cast `{$expr_ty}` to a pointer that {$known_wide -> [true] is diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 8baa671972139..f3ca04c6bbe27 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -2448,7 +2448,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .tcx .inherent_impls(def_id) .into_iter() - .flat_map(|i| self.tcx.associated_items(i).in_definition_order()) + .flat_map(|&i| self.tcx.associated_items(i).in_definition_order()) // Only assoc fn with no receivers. .filter(|item| item.is_fn() && !item.is_method()) .filter_map(|item| { @@ -3183,7 +3183,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check if there is an associated function with the same name. if let Some(def_id) = base_ty.peel_refs().ty_adt_def().map(|d| d.did()) { - for impl_def_id in self.tcx.inherent_impls(def_id) { + for &impl_def_id in self.tcx.inherent_impls(def_id) { for item in self.tcx.associated_items(impl_def_id).in_definition_order() { if let ExprKind::Field(base_expr, _) = expr.kind && item.name() == field.name diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index e8d5ff017cf8c..1931222bba30e 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1118,7 +1118,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // error in `validate_res_from_ribs` -- it's just difficult to tell whether the // self type has any generic types during rustc_resolve, which is what we use // to determine if this is a hard error or warning. - if std::iter::successors(Some(self.body_id.to_def_id()), |def_id| { + if std::iter::successors(Some(self.body_id.to_def_id()), |&def_id| { self.tcx.generics_of(def_id).parent }) .all(|def_id| def_id != impl_def_id) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index bdc991abf34b8..c82a779ca8326 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -567,7 +567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } if self.may_coerce(Ty::new_box(self.tcx, found), expected) { - let suggest_boxing = match found.kind() { + let suggest_boxing = match *found.kind() { ty::Tuple(tuple) if tuple.is_empty() => { errors::SuggestBoxing::Unit { start: span.shrink_to_lo(), end: span } } diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index c5e055e68aea1..862a51288730d 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1414,7 +1414,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }) .collect::>(); if !inherent_impls_candidate.is_empty() { - inherent_impls_candidate.sort_by_key(|id| self.tcx.def_path_str(id)); + inherent_impls_candidate.sort_by_key(|&id| self.tcx.def_path_str(id)); inherent_impls_candidate.dedup(); // number of types to show at most @@ -2256,7 +2256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { call_args: Option>>, ) -> Option { if let ty::Adt(adt, adt_args) = rcvr_ty.kind() { - for inherent_impl_did in self.tcx.inherent_impls(adt.did()).into_iter() { + for &inherent_impl_did in self.tcx.inherent_impls(adt.did()).into_iter() { for inherent_method in self.tcx.associated_items(inherent_impl_did).in_definition_order() { @@ -2315,7 +2315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sources: &mut Vec, sugg_span: Option, ) { - sources.sort_by_key(|source| match source { + sources.sort_by_key(|source| match *source { CandidateSource::Trait(id) => (0, self.tcx.def_path_str(id)), CandidateSource::Impl(id) => (1, self.tcx.def_path_str(id)), }); @@ -2468,7 +2468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .tcx .inherent_impls(adt_def.did()) .iter() - .flat_map(|i| self.tcx.associated_items(i).in_definition_order()) + .flat_map(|&i| self.tcx.associated_items(i).in_definition_order()) // Only assoc fn with no receivers and only if // they are resolvable .filter(|item| { @@ -2521,7 +2521,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { String::new() }; - match &items[..] { + match items[..] { [] => {} [(def_id, ret_ty)] => { err.span_note( @@ -2536,7 +2536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => { let span: MultiSpan = items .iter() - .map(|(def_id, _)| self.tcx.def_span(def_id)) + .map(|&(def_id, _)| self.tcx.def_span(def_id)) .collect::>() .into(); err.span_note( @@ -2546,7 +2546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { following associated functions:\n{}{post}", items .iter() - .map(|(def_id, _ret_ty)| self.tcx.def_path_str(def_id)) + .map(|&(def_id, _ret_ty)| self.tcx.def_path_str(def_id)) .collect::>() .join("\n") ), @@ -3518,7 +3518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { traits.push(trait_pred.def_id()); } } - traits.sort_by_key(|id| self.tcx.def_path_str(id)); + traits.sort_by_key(|&id| self.tcx.def_path_str(id)); traits.dedup(); let len = traits.len(); @@ -3920,7 +3920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { valid_out_of_scope_traits.retain(|id| self.tcx.is_user_visible_dep(id.krate)); if !valid_out_of_scope_traits.is_empty() { let mut candidates = valid_out_of_scope_traits; - candidates.sort_by_key(|id| self.tcx.def_path_str(id)); + candidates.sort_by_key(|&id| self.tcx.def_path_str(id)); candidates.dedup(); // `TryFrom` and `FromIterator` have no methods diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index cb75e8a943b3e..e9d79a2ece2ec 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -380,8 +380,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx .associated_item_def_ids(def_id) .iter() - .find(|item_def_id| { - self.tcx.associated_item(*item_def_id).name() == sym::Output + .find(|&&item_def_id| { + self.tcx.associated_item(item_def_id).name() == sym::Output }) .cloned() }); diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 5e5f9b6f097fa..c7fa779447a49 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -308,7 +308,7 @@ where return true; }; // We only computed variance of lifetimes... - debug_assert_matches!(self.tcx.def_kind(def_id), DefKind::LifetimeParam); + debug_assert_matches!(self.tcx.def_kind(*def_id), DefKind::LifetimeParam); let uncaptured = match *kind { ParamKind::Early(name, index) => ty::Region::new_early_param( self.tcx, @@ -342,7 +342,7 @@ where let uncaptured_spans: Vec<_> = uncaptured_args .into_iter() - .map(|(def_id, _)| self.tcx.def_span(def_id)) + .map(|(&def_id, _)| self.tcx.def_span(def_id)) .collect(); self.tcx.emit_node_span_lint( diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 87c36f41afab1..0723395d6d1cd 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -282,9 +282,9 @@ fn lint_ty_kind_usage(cx: &LateContext<'_>, res: &Res) -> bool { } fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, path: &hir::Path<'_>) -> Option { - match &path.res { + match path.res { Res::Def(_, def_id) => { - if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(*def_id) { + if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(def_id) { return Some(format!("{}{}", name, gen_args(path.segments.last().unwrap()))); } } diff --git a/compiler/rustc_middle/src/mir/graphviz.rs b/compiler/rustc_middle/src/mir/graphviz.rs index cbfeae2051777..30a781b025fd5 100644 --- a/compiler/rustc_middle/src/mir/graphviz.rs +++ b/compiler/rustc_middle/src/mir/graphviz.rs @@ -16,12 +16,12 @@ where let mirs = def_ids .iter() - .filter(|def_id| !tcx.is_trivial_const(*def_id)) - .flat_map(|def_id| { - if tcx.is_const_fn(*def_id) { - vec![tcx.optimized_mir(*def_id), tcx.mir_for_ctfe(*def_id)] + .filter(|&&def_id| !tcx.is_trivial_const(def_id)) + .flat_map(|&def_id| { + if tcx.is_const_fn(def_id) { + vec![tcx.optimized_mir(def_id), tcx.mir_for_ctfe(def_id)] } else { - vec![tcx.instance_mir(ty::InstanceKind::Item(*def_id))] + vec![tcx.instance_mir(ty::InstanceKind::Item(def_id))] } }) .collect::>(); diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index a4ab1f364c168..654404f9790cb 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -309,7 +309,7 @@ impl<'tcx> GlobalAlloc<'tcx> { pub fn mutability(&self, tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> Mutability { // Let's see what kind of memory we are. - match self { + match *self { GlobalAlloc::Static(did) => { let DefKind::Static { safety: _, mutability, nested } = tcx.def_kind(did) else { bug!() @@ -351,7 +351,7 @@ impl<'tcx> GlobalAlloc<'tcx> { tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>, ) -> (Size, Align) { - match self { + match *self { GlobalAlloc::Static(def_id) => { let DefKind::Static { nested, .. } = tcx.def_kind(def_id) else { bug!("GlobalAlloc::Static is not a static") diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 03618ee6acd46..6b19bf23edc2f 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -633,13 +633,6 @@ mod sealed { } } - impl<'a, P: Copy> IntoQueryParam

for &'a P { - #[inline(always)] - fn into_query_param(self) -> P { - *self - } - } - impl IntoQueryParam for OwnerId { #[inline(always)] fn into_query_param(self) -> LocalDefId { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 47843a260440e..be8a6083b0cde 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2086,7 +2086,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Given a `ty`, return whether it's an `impl Future<...>`. pub fn ty_is_opaque_future(self, ty: Ty<'_>) -> bool { - let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = ty.kind() else { return false }; + let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *ty.kind() else { return false }; let future_trait = self.require_lang_item(LangItem::Future, DUMMY_SP); self.explicit_item_self_bounds(def_id).skip_binder().iter().any(|&(predicate, _)| { diff --git a/compiler/rustc_middle/src/ty/significant_drop_order.rs b/compiler/rustc_middle/src/ty/significant_drop_order.rs index f1aa7076d98ac..5035127b8c9ca 100644 --- a/compiler/rustc_middle/src/ty/significant_drop_order.rs +++ b/compiler/rustc_middle/src/ty/significant_drop_order.rs @@ -119,7 +119,7 @@ pub fn extract_component_with_significant_dtor<'tcx>( /// when we are working with current local crate. #[instrument(level = "trace", skip(tcx))] pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { - match ty.kind() { + match *ty.kind() { ty::Bool | ty::Char | ty::Int(_) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index c3be0b630d6ed..c29f3e7458e54 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -417,7 +417,7 @@ impl<'tcx> TyCtxt<'tcx> { continue; } - let Some(item_id) = self.associated_item_def_ids(impl_did).first() else { + let Some(&item_id) = self.associated_item_def_ids(impl_did).first() else { self.dcx() .span_delayed_bug(self.def_span(impl_did), "Drop impl without drop function"); continue; @@ -435,7 +435,7 @@ impl<'tcx> TyCtxt<'tcx> { .delay_as_bug(); } - dtor_candidate = Some(*item_id); + dtor_candidate = Some(item_id); } let did = dtor_candidate?; diff --git a/compiler/rustc_mir_build/src/builder/expr/into.rs b/compiler/rustc_mir_build/src/builder/expr/into.rs index e8427b5d6e1eb..24d184121ffd0 100644 --- a/compiler/rustc_mir_build/src/builder/expr/into.rs +++ b/compiler/rustc_mir_build/src/builder/expr/into.rs @@ -370,7 +370,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Some intrinsics are handled here because they desperately want to avoid introducing // unnecessary copies. ExprKind::Call { ty, fun, ref args, .. } - if let ty::FnDef(def_id, generic_args) = ty.kind() + if let ty::FnDef(def_id, generic_args) = *ty.kind() && let Some(intrinsic) = this.tcx.intrinsic(def_id) && matches!(intrinsic.name, sym::write_via_move | sym::write_box_via_move) => { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 001c4338ad0e1..24c85b7ec3f5d 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -471,7 +471,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => { let fn_ty = self.thir[fun].ty; let sig = fn_ty.fn_sig(self.tcx); - let (callee_features, safe_target_features): (&[_], _) = match fn_ty.kind() { + let (callee_features, safe_target_features): (&[_], _) = match *fn_ty.kind() { ty::FnDef(func_id, ..) => { let cg_attrs = self.tcx.codegen_fn_attrs(func_id); (&cg_attrs.target_features, cg_attrs.safe_target_features) diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index 8998be26412d5..f33e43162c3f4 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -251,19 +251,16 @@ where // impl_item_refs may be empty if drop fn is not implemented in 'impl AsyncDrop for ...' // (#140974). // Such code will report error, so just generate sync drop here and return - let Some(drop_fn_def_id) = tcx - .associated_item_def_ids(drop_trait) - .first() - .and_then(|def_id| { + let Some(drop_fn_def_id) = + tcx.associated_item_def_ids(drop_trait).first().and_then(|&def_id| { if tcx.def_kind(def_id) == DefKind::AssocFn - && tcx.check_args_compatible(*def_id, trait_args) + && tcx.check_args_compatible(def_id, trait_args) { Some(def_id) } else { None } }) - .copied() else { tcx.dcx().span_delayed_bug( self.elaborator.body().span, diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 78c161ebd58c9..656b74e15f727 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -440,7 +440,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { } } - if let ty::FnDef(did, ..) = func.ty(&self.body.local_decls, self.tcx).kind() + if let ty::FnDef(did, ..) = *func.ty(&self.body.local_decls, self.tcx).kind() && self.body.phase >= MirPhase::Runtime(RuntimePhase::Optimized) && matches!(self.tcx.codegen_fn_attrs(did).inline, InlineAttr::Force { .. }) { diff --git a/compiler/rustc_monomorphize/src/collector/autodiff.rs b/compiler/rustc_monomorphize/src/collector/autodiff.rs index e3646596e75e6..67d4b8c8afff2 100644 --- a/compiler/rustc_monomorphize/src/collector/autodiff.rs +++ b/compiler/rustc_monomorphize/src/collector/autodiff.rs @@ -28,13 +28,13 @@ fn collect_autodiff_fn_from_arg<'tcx>( output: &mut MonoItems<'tcx>, ) { let (instance, span) = match arg.kind() { - ty::GenericArgKind::Type(ty) => match ty.kind() { + ty::GenericArgKind::Type(ty) => match *ty.kind() { ty::FnDef(def_id, substs) => { let span = tcx.def_span(def_id); let instance = ty::Instance::expect_resolve( tcx, ty::TypingEnv::non_body_analysis(tcx, def_id), - *def_id, + def_id, substs, span, ); diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index 249c5e6397461..abe63e073ad78 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -37,7 +37,7 @@ fn custom_coerce_unsize_info<'tcx>( Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData { impl_def_id, .. - })) => Ok(tcx.coerce_unsized_info(impl_def_id)?.custom_kind.unwrap()), + })) => Ok(tcx.coerce_unsized_info(*impl_def_id)?.custom_kind.unwrap()), impl_source => { bug!( "invalid `CoerceUnsized` from {source_ty} to {target_ty}: impl_source: {:?}", diff --git a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs index 0adf1b089b53e..a8f3104c0d98d 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/move_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/move_check.rs @@ -190,7 +190,7 @@ impl<'tcx> MoveCheckVisitor<'tcx> { } fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option { - for impl_def_id in tcx.inherent_impls(def_id) { + for &impl_def_id in tcx.inherent_impls(def_id) { if let Some(new) = tcx.associated_items(impl_def_id).find_by_ident_and_kind( tcx, fn_ident, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index ad667df47123f..b01afe550e74f 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2207,7 +2207,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }) }) .collect(); - if let Some(def_id) = path.get(0) + if let Some(&def_id) = path.get(0) && let Some(path) = path_names { if let Some(def_id) = def_id.as_local() { diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 59a5c0728a753..0fba8295afbac 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1295,7 +1295,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { .tcx .associated_item_def_ids(def_id) .iter() - .map(|field_id| self.tcx.visibility(field_id)) + .map(|&field_id| self.tcx.visibility(field_id)) .collect(); (ctor_res, ctor_vis, field_visibilities) }) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index b1d6e3526d9cd..9f5196d894893 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -2359,7 +2359,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .tcx .associated_item_def_ids(def_id) .iter() - .map(|field_id| self.r.tcx.visibility(field_id)) + .map(|&field_id| self.r.tcx.visibility(field_id)) .collect(); (ctor_res, ctor_vis, field_visibilities) }) @@ -2594,7 +2594,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .tcx .inherent_impls(def_id) .iter() - .flat_map(|i| self.r.tcx.associated_items(i).in_definition_order()) + .flat_map(|&i| self.r.tcx.associated_items(i).in_definition_order()) // Only assoc fn with no receivers. .filter(|item| item.is_fn() && !item.is_method()) .filter_map(|item| { @@ -2702,7 +2702,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .tcx .associated_item_def_ids(def_id) .iter() - .map(|field_id| self.r.tcx.visibility(field_id)) + .map(|&field_id| self.r.tcx.visibility(field_id)) .collect(), ), }; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs index 16c4ac68cdf0c..060204946d014 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs @@ -362,7 +362,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { && self.tcx.trait_of_assoc(*item_id) == Some(*trait_id) && let None = self.tainted_by_errors() { - let assoc_item = self.tcx.associated_item(item_id); + let assoc_item = self.tcx.associated_item(*item_id); let (verb, noun) = match assoc_item.kind { ty::AssocKind::Const { .. } => ("refer to the", "constant"), ty::AssocKind::Fn { .. } => ("call", "function"), @@ -394,7 +394,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let trait_impls = self.tcx.trait_impls_of(data.trait_ref.def_id); - if let Some(impl_def_id) = + if let Some(&impl_def_id) = trait_impls.non_blanket_impls().values().flatten().next() { let non_blanket_impl_count = @@ -418,7 +418,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { .non_blanket_impls() .values() .flatten() - .map(|id| { + .map(|&id| { format!( "{}", self.tcx.type_of(id).instantiate_identity() diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 2c7105ab4ebea..983890f6b48db 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1799,7 +1799,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { with_forced_trimmed_paths! { if self.tcx.is_lang_item(projection_term.def_id, LangItem::FnOnceOutput) { - let (span, closure_span) = if let ty::Closure(def_id, _) = self_ty.kind() { + let (span, closure_span) = if let ty::Closure(def_id, _) = *self_ty.kind() { let def_span = self.tcx.def_span(def_id); if let Some(local_def_id) = def_id.as_local() && let node = self.tcx.hir_node_by_def_id(local_def_id) @@ -2305,7 +2305,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; if candidates.len() < 5 { let spans: Vec<_> = - candidates.iter().map(|(_, def_id)| self.tcx.def_span(def_id)).collect(); + candidates.iter().map(|&(_, def_id)| self.tcx.def_span(def_id)).collect(); let mut span: MultiSpan = spans.into(); for (c, def_id) in &candidates { let msg = if all_traits_equal { @@ -2317,7 +2317,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx.short_string(c.print_only_trait_path(), err.long_ty_path()), ) }; - span.push_span_label(self.tcx.def_span(def_id), msg); + span.push_span_label(self.tcx.def_span(*def_id), msg); } err.span_help( span, @@ -2631,16 +2631,16 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ) }; let trait_name = self.tcx.item_name(trait_def_id); - if let Some(other_trait_def_id) = self.tcx.all_traits_including_private().find(|def_id| { - trait_def_id != *def_id + if let Some(other_trait_def_id) = self.tcx.all_traits_including_private().find(|&def_id| { + trait_def_id != def_id && trait_name == self.tcx.item_name(def_id) - && trait_has_same_params(*def_id) + && trait_has_same_params(def_id) && self.predicate_must_hold_modulo_regions(&Obligation::new( self.tcx, obligation.cause.clone(), obligation.param_env, trait_pred.map_bound(|tr| ty::TraitPredicate { - trait_ref: ty::TraitRef::new(self.tcx, *def_id, tr.trait_ref.args), + trait_ref: ty::TraitRef::new(self.tcx, def_id, tr.trait_ref.args), ..tr }), )) @@ -3314,7 +3314,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { terr: TypeError<'tcx>, ) -> Diag<'a> { let self_ty = found_trait_ref.self_ty(); - let (cause, terr) = if let ty::Closure(def_id, _) = self_ty.kind() { + let (cause, terr) = if let ty::Closure(def_id, _) = *self_ty.kind() { ( ObligationCause::dummy_with_span(self.tcx.def_span(def_id)), TypeError::CyclicTy(self_ty), diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index a7a685d62b345..c239f0b56c83f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -373,12 +373,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx.extern_crate(trait_def_id.krate), ) { ( - Some(ExternCrate { + Some(&ExternCrate { src: ExternCrateSource::Extern(expected_def_id), dependency_of: LOCAL_CRATE, .. }), - Some(ExternCrate { + Some(&ExternCrate { src: ExternCrateSource::Extern(trait_def_id), dependency_of: LOCAL_CRATE, .. @@ -402,9 +402,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let krate = self.tcx.crate_name(expected_did.krate); let name = self.tcx.item_name(expected_did); let definitions_with_same_path: UnordSet<_> = found_dids - .filter(|def_id| { + .filter(|&def_id| { def_id.krate != expected_did.krate - && (self.extern_crates_with_the_same_name(expected_did, *def_id) + && (self.extern_crates_with_the_same_name(expected_did, def_id) || self.tcx.crate_name(def_id.krate) == krate) && self.tcx.item_name(def_id) == name }) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs index 9c146d7326135..0af7b0e3253dd 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs @@ -207,7 +207,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if self_ty.is_fn() { let fn_sig = self_ty.fn_sig(self.tcx); - let shortname = if let ty::FnDef(def_id, _) = self_ty.kind() + let shortname = if let ty::FnDef(def_id, _) = *self_ty.kind() && self.tcx.codegen_fn_attrs(def_id).safe_target_features { "#[target_feature] fn" diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs index 8488d76e2c773..360a01a8a3759 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented_format.rs @@ -231,7 +231,7 @@ fn parse_arg<'tcx>( is_source_literal: bool, ) -> FormatArg { let (Ctx::RustcOnUnimplemented { tcx, trait_def_id } - | Ctx::DiagnosticOnUnimplemented { tcx, trait_def_id }) = ctx; + | Ctx::DiagnosticOnUnimplemented { tcx, trait_def_id }) = *ctx; let span = slice_span(input_span, arg.position_span.clone(), is_source_literal); diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 18b926ad28c89..176cc8c4c2cab 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -2244,9 +2244,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // First, look for an `WhereClauseInExpr`, which means we can get // the uninstantiated predicate list of the called function. And check // that the predicate that we failed to satisfy is a `Fn`-like trait. - if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = cause + if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = *cause && let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx) - && let Some(pred) = predicates.predicates.get(*idx) + && let Some(pred) = predicates.predicates.get(idx) && let ty::ClauseKind::Trait(trait_pred) = pred.kind().skip_binder() && self.tcx.is_fn_trait(trait_pred.def_id()) { @@ -2257,7 +2257,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // Find another predicate whose self-type is equal to the expected self type, // but whose args don't match. - let other_pred = predicates.into_iter().enumerate().find(|(other_idx, (pred, _))| { + let other_pred = predicates.into_iter().enumerate().find(|&(other_idx, (pred, _))| { match pred.kind().skip_binder() { ty::ClauseKind::Trait(trait_pred) if self.tcx.is_fn_trait(trait_pred.def_id()) @@ -3029,10 +3029,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let len = impls.len(); let mut types = impls .iter() - .map(|t| { + .map(|&&t| { with_no_trimmed_paths!(format!( " {}", - tcx.type_of(*t).instantiate_identity(), + tcx.type_of(t).instantiate_identity(), )) }) .collect::>(); @@ -3421,7 +3421,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let ty_str = tcx.short_string(ty, err.long_ty_path()); format!("required because it appears within the type `{ty_str}`") }; - match ty.kind() { + match *ty.kind() { ty::Adt(def, _) => { let msg = msg(); match tcx.opt_item_ident(def.did()) { @@ -4216,11 +4216,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // to an associated type (as seen from `trait_pred`) in the predicate. Like in // trait_pred `S: Sum<::Item>` and predicate `i32: Sum<&()>` let mut type_diffs = vec![]; - if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = parent_code + if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = *parent_code && let Some(node_args) = typeck_results.node_args_opt(call_hir_id) && let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args) - && let Some(where_pred) = where_clauses.predicates.get(*idx) + && let Some(where_pred) = where_clauses.predicates.get(idx) { if let Some(where_pred) = where_pred.as_trait_clause() && let Some(failed_pred) = failed_pred.as_trait_clause() diff --git a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs index 2e60805cd10a5..8a61d9a021752 100644 --- a/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs +++ b/compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs @@ -267,7 +267,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( return; } - match ty.kind() { + match *ty.kind() { ty::Bool | ty::Char | ty::Int(_) @@ -287,7 +287,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>( ty::Pat(ety, _) | ty::Array(ety, _) | ty::Slice(ety) => { // single-element containers, behave like their element rustc_data_structures::stack::ensure_sufficient_stack(|| { - dtorck_constraint_for_ty_inner(tcx, typing_env, span, depth + 1, *ety, constraints) + dtorck_constraint_for_ty_inner(tcx, typing_env, span, depth + 1, ety, constraints) }); } diff --git a/library/alloctests/tests/lib.rs b/library/alloctests/tests/lib.rs index 699a5010282b0..f18d6e1bb3794 100644 --- a/library/alloctests/tests/lib.rs +++ b/library/alloctests/tests/lib.rs @@ -33,7 +33,6 @@ #![feature(thin_box)] #![feature(drain_keep_rest)] #![feature(local_waker)] -#![feature(str_as_str)] #![feature(strict_provenance_lints)] #![feature(string_replace_in_place)] #![feature(vec_deque_truncate_front)] diff --git a/library/core/src/bstr/mod.rs b/library/core/src/bstr/mod.rs index 34e1ea66c99ad..3e3b78b452e01 100644 --- a/library/core/src/bstr/mod.rs +++ b/library/core/src/bstr/mod.rs @@ -74,7 +74,6 @@ impl ByteStr { /// it helps dereferencing other "container" types, /// for example `Box` or `Arc`. #[inline] - // #[unstable(feature = "str_as_str", issue = "130366")] #[unstable(feature = "bstr", issue = "134915")] pub const fn as_byte_str(&self) -> &ByteStr { self @@ -86,7 +85,6 @@ impl ByteStr { /// it helps dereferencing other "container" types, /// for example `Box` or `MutexGuard`. #[inline] - // #[unstable(feature = "str_as_str", issue = "130366")] #[unstable(feature = "bstr", issue = "134915")] pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr { self diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 621277179bb38..8097066a57339 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -655,7 +655,8 @@ impl CStr { /// it helps dereferencing other string-like types to string slices, /// for example references to `Box` or `Arc`. #[inline] - #[unstable(feature = "str_as_str", issue = "130366")] + #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] pub const fn as_c_str(&self) -> &CStr { self } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 36dd4d6782ac1..ac3088142f7df 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -5337,7 +5337,8 @@ impl [T] { /// it helps dereferencing other "container" types to slices, /// for example `Box<[T]>` or `Arc<[T]>`. #[inline] - #[unstable(feature = "str_as_str", issue = "130366")] + #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] pub const fn as_slice(&self) -> &[T] { self } @@ -5348,7 +5349,8 @@ impl [T] { /// it helps dereferencing other "container" types to slices, /// for example `Box<[T]>` or `MutexGuard<[T]>`. #[inline] - #[unstable(feature = "str_as_str", issue = "130366")] + #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] pub const fn as_mut_slice(&mut self) -> &mut [T] { self } diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 98354643aa405..2d7fdb824d1f8 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -3137,7 +3137,8 @@ impl str { /// it helps dereferencing other string-like types to string slices, /// for example references to `Box` or `Arc`. #[inline] - #[unstable(feature = "str_as_str", issue = "130366")] + #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] pub const fn as_str(&self) -> &str { self } diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index ca910153e5260..6b4cf3cea831c 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1285,7 +1285,8 @@ impl OsStr { /// it helps dereferencing other string-like types to string slices, /// for example references to `Box` or `Arc`. #[inline] - #[unstable(feature = "str_as_str", issue = "130366")] + #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] pub const fn as_os_str(&self) -> &OsStr { self } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index bf27df7b04281..712031ff7ccb1 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -3235,7 +3235,8 @@ impl Path { /// it helps dereferencing other `PathBuf`-like types to `Path`s, /// for example references to `Box` or `Arc`. #[inline] - #[unstable(feature = "str_as_str", issue = "130366")] + #[stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "str_as_str", since = "CURRENT_RUSTC_VERSION")] pub const fn as_path(&self) -> &Path { self } diff --git a/library/std/tests/sync/oneshot.rs b/library/std/tests/sync/oneshot.rs index 8e63a26fa3ac8..6eaacfbc6497d 100644 --- a/library/std/tests/sync/oneshot.rs +++ b/library/std/tests/sync/oneshot.rs @@ -243,7 +243,9 @@ fn recv_deadline_passed() { } assert!(start.elapsed() >= timeout); - assert!(start.elapsed() < timeout * 3); + // FIXME(#152878): An upper-bound assertion on the elapsed time was removed, + // because CI runners can starve individual threads for a surprisingly long + // time, leading to flaky failures. } #[test] @@ -252,12 +254,16 @@ fn recv_time_passed() { let start = Instant::now(); let timeout = Duration::from_millis(100); + match receiver.recv_timeout(timeout) { Err(RecvTimeoutError::Timeout(_)) => {} _ => panic!("expected timeout error"), } + assert!(start.elapsed() >= timeout); - assert!(start.elapsed() < timeout * 3); + // FIXME(#152878): An upper-bound assertion on the elapsed time was removed, + // because CI runners can starve individual threads for a surprisingly long + // time, leading to flaky failures. } #[test] diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 9c7685ca30bc9..fb0dbac7c41df 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -191,7 +191,7 @@ pub(crate) fn try_inline_glob( .iter() .filter(|child| !child.reexport_chain.is_empty()) .filter_map(|child| child.res.opt_def_id()) - .filter(|def_id| !cx.tcx.is_doc_hidden(def_id)) + .filter(|&def_id| !cx.tcx.is_doc_hidden(def_id)) .collect(); let attrs = cx.tcx.hir_attrs(import.hir_id()); let mut items = build_module_items( diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 927a7e0f07159..b58daceed0702 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -94,7 +94,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> // While the `impl` blocks themselves are only in `libcore`, the module with `doc` // attached is directly included in `libstd` as well. if did.is_local() { - for def_id in prim.impls(tcx).filter(|def_id| { + for def_id in prim.impls(tcx).filter(|&def_id| { // Avoid including impl blocks with filled-in generics. // https://github.com/rust-lang/rust/issues/94937 // diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index bb94a111f7a14..20cf3796c8be9 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -150,16 +150,16 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx let callee_ty_adjustments = typeck.expr_adjustments(callee); let callee_ty_adjusted = callee_ty_adjustments.last().map_or(callee_ty, |a| a.target); - let sig = match callee_ty_adjusted.kind() { + let sig = match *callee_ty_adjusted.kind() { ty::FnDef(def, _) => { // Rewriting `x(|| f())` to `x(f)` where f is marked `#[track_caller]` moves the `Location` - if find_attr!(cx.tcx, *def, TrackCaller(..)) { + if find_attr!(cx.tcx, def, TrackCaller(..)) { return; } cx.tcx.fn_sig(def).skip_binder().skip_binder() }, - ty::FnPtr(sig_tys, hdr) => sig_tys.with(*hdr).skip_binder(), + ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr).skip_binder(), ty::Closure(_, subs) => cx .tcx .signature_unclosure(subs.as_closure().sig(), Safety::Safe) diff --git a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs index aed4a0075c2fd..832197d36cc65 100644 --- a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs +++ b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs @@ -133,7 +133,7 @@ fn check_unwrap_or_default( let output_type_implements_default = |fun| { let fun_ty = cx.typeck_results().expr_ty(fun); - if let ty::FnDef(def_id, args) = fun_ty.kind() { + if let ty::FnDef(def_id, args) = *fun_ty.kind() { let output_ty = cx.tcx.fn_sig(def_id).instantiate(cx.tcx, args).skip_binder().output(); cx.tcx .get_diagnostic_item(sym::Default) @@ -153,7 +153,7 @@ fn check_unwrap_or_default( cx.tcx .inherent_impls(adt_def.did()) .iter() - .flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg)) + .flat_map(|&impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg)) .find_map(|assoc| { if assoc.is_method() && cx.tcx.fn_sig(assoc.def_id).skip_binder().inputs().skip_binder().len() == 1 { Some(assoc.def_id) diff --git a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs index 43c62e1e131a3..92515bd3fb804 100644 --- a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs +++ b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs @@ -287,7 +287,7 @@ fn is_assoc_fn_without_type_instance<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<' .. }, )) = func.kind - && let output_ty = cx.tcx.fn_sig(def_id).instantiate_identity().skip_binder().output() + && let output_ty = cx.tcx.fn_sig(*def_id).instantiate_identity().skip_binder().output() && let ty::Param(ty::ParamTy { name: kw::SelfUpper, .. }) = output_ty.kind() diff --git a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs index c1e03b7e8c705..1b7d7fd6c68cb 100644 --- a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs @@ -335,8 +335,8 @@ impl UnconditionalRecursion { let impls = cx.tcx.trait_impls_of(default_trait_id); for (ty, impl_def_ids) in impls.non_blanket_impls() { let Some(self_def_id) = ty.def() else { continue }; - for impl_def_id in impl_def_ids { - if !cx.tcx.is_automatically_derived(*impl_def_id) && + for &impl_def_id in impl_def_ids { + if !cx.tcx.is_automatically_derived(impl_def_id) && let Some(assoc_item) = cx .tcx .associated_items(impl_def_id) diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 9a49845d9d46b..fdd270c2774af 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -601,9 +601,9 @@ pub fn is_default_equivalent_call( && let StatementKind::Assign(assign) = &block_data.statements[0].kind && assign.0.local == RETURN_PLACE && let Rvalue::Aggregate(kind, _places) = &assign.1 - && let AggregateKind::Adt(did, variant_index, _, _, _) = &**kind + && let AggregateKind::Adt(did, variant_index, _, _, _) = **kind && let def = cx.tcx.adt_def(did) - && let variant = &def.variant(*variant_index) + && let variant = &def.variant(variant_index) && variant.fields.is_empty() && let Some((_, did)) = variant.ctor && did == repl_def_id diff --git a/src/tools/clippy/clippy_utils/src/paths.rs b/src/tools/clippy/clippy_utils/src/paths.rs index 8aa663163caf1..e6593aa8b5541 100644 --- a/src/tools/clippy/clippy_utils/src/paths.rs +++ b/src/tools/clippy/clippy_utils/src/paths.rs @@ -335,7 +335,7 @@ fn non_local_item_child_by_name(tcx: TyCtxt<'_>, def_id: DefId, ns: PathNS, name .associated_item_def_ids(def_id) .iter() .copied() - .find(|assoc_def_id| tcx.item_name(*assoc_def_id) == name && ns.matches(tcx.def_kind(assoc_def_id).ns())), + .find(|&assoc_def_id| tcx.item_name(assoc_def_id) == name && ns.matches(tcx.def_kind(assoc_def_id).ns())), _ => None, } } diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index 3e1ad6c0ef515..36410a81fbf65 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -310,13 +310,13 @@ pub fn has_drop<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { // Returns whether the type has #[must_use] attribute pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { - match ty.kind() { + match *ty.kind() { ty::Adt(adt, _) => find_attr!(cx.tcx, adt.did(), MustUse { .. }), - ty::Foreign(did) => find_attr!(cx.tcx, *did, MustUse { .. }), + ty::Foreign(did) => find_attr!(cx.tcx, did, MustUse { .. }), ty::Slice(ty) | ty::Array(ty, _) | ty::RawPtr(ty, _) | ty::Ref(_, ty, _) => { // for the Array case we don't need to care for the len == 0 case // because we don't want to lint functions returning empty arrays - is_must_use_ty(cx, *ty) + is_must_use_ty(cx, ty) }, ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)), ty::Alias(ty::Opaque, AliasTy { def_id, .. }) => { @@ -330,7 +330,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { false }, ty::Dynamic(binder, _) => { - for predicate in *binder { + for predicate in binder { if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate.skip_binder() && find_attr!(cx.tcx, trait_ref.def_id, MustUse { .. }) { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9df9db5b4b69c..fce3269b149a0 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -504,12 +504,11 @@ impl<'test> TestCx<'test> { let normalized_revision = normalize_revision(revision); let cfg_arg = ["--cfg", &normalized_revision]; let arg = format!("--cfg={normalized_revision}"); - if self - .props - .compile_flags - .windows(2) - .any(|args| args == cfg_arg || args[0] == arg || args[1] == arg) - { + // Handle if compile_flags is length 1 + let contains_arg = + self.props.compile_flags.iter().any(|considered_arg| *considered_arg == arg); + let contains_cfg_arg = self.props.compile_flags.windows(2).any(|args| args == cfg_arg); + if contains_arg || contains_cfg_arg { error!( "redundant cfg argument `{normalized_revision}` is already created by the \ revision" diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 5dcd2d9ec2084..facfade026be8 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -62,7 +62,7 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option) // Go over the modules. for &segment in modules { let Some(next_item) = find_children(tcx, cur_item, segment) - .find(|item| tcx.def_kind(item) == DefKind::Mod) + .find(|&item| tcx.def_kind(item) == DefKind::Mod) else { continue 'crates; }; @@ -72,7 +72,7 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option) match item { Some((item_name, namespace)) => { let Some(item) = find_children(tcx, cur_item, item_name) - .find(|item| tcx.def_kind(item).ns() == Some(namespace)) + .find(|&item| tcx.def_kind(item).ns() == Some(namespace)) else { continue 'crates; }; diff --git a/src/tools/wasm-component-ld/Cargo.toml b/src/tools/wasm-component-ld/Cargo.toml index 2d44358c74334..3f20b9e3fa12e 100644 --- a/src/tools/wasm-component-ld/Cargo.toml +++ b/src/tools/wasm-component-ld/Cargo.toml @@ -10,4 +10,4 @@ name = "wasm-component-ld" path = "src/main.rs" [dependencies] -wasm-component-ld = "0.5.20" +wasm-component-ld = "0.5.21" diff --git a/tests/codegen-llvm/dst-vtable-align-nonzero.rs b/tests/codegen-llvm/dst-vtable-align-nonzero.rs index 1404bd64f500c..2eee91876683c 100644 --- a/tests/codegen-llvm/dst-vtable-align-nonzero.rs +++ b/tests/codegen-llvm/dst-vtable-align-nonzero.rs @@ -64,4 +64,4 @@ pub unsafe fn align_load_from_vtable_align_intrinsic(x: &dyn Trait) -> usize { core::intrinsics::vtable_align(vtable) } -// CHECK: [[RANGE_META]] = !{[[USIZE]] 1, [[USIZE]] 0} +// CHECK: [[RANGE_META]] = !{[[USIZE]] 1, [[USIZE]] [[#0x20000001]] diff --git a/tests/mir-opt/pre-codegen/copy_and_clone.rs b/tests/mir-opt/pre-codegen/copy_and_clone.rs index 05da25afa2a39..eb3c2eacc248b 100644 --- a/tests/mir-opt/pre-codegen/copy_and_clone.rs +++ b/tests/mir-opt/pre-codegen/copy_and_clone.rs @@ -1,4 +1,3 @@ -//@ [COPY] compile-flags: --cfg=copy //@ revisions: COPY CLONE // Test case from https://github.com/rust-lang/rust/issues/128081. diff --git a/tests/ui/scalable-vectors/illegal_init.rs b/tests/ui/scalable-vectors/illegal_init.rs new file mode 100644 index 0000000000000..e8c0447fea422 --- /dev/null +++ b/tests/ui/scalable-vectors/illegal_init.rs @@ -0,0 +1,10 @@ +#![allow(incomplete_features, internal_features)] +#![feature(rustc_attrs)] + +#[rustc_scalable_vector(4)] +#[allow(non_camel_case_types)] +struct svint32_t(i32); +fn main() { + let foo = svint32_t(1); + //~^ ERROR: scalable vector types cannot be initialised using their constructor +} diff --git a/tests/ui/scalable-vectors/illegal_init.stderr b/tests/ui/scalable-vectors/illegal_init.stderr new file mode 100644 index 0000000000000..db0fffcf3b772 --- /dev/null +++ b/tests/ui/scalable-vectors/illegal_init.stderr @@ -0,0 +1,8 @@ +error: scalable vector types cannot be initialised using their constructor + --> $DIR/illegal_init.rs:8:15 + | +LL | let foo = svint32_t(1); + | ^^^^^^^^^ you can create scalable vectors using intrinsics + +error: aborting due to 1 previous error +