From 314a75b0251d7efd12bc6897fbe16661d9983755 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Wed, 16 Sep 2026 14:50:31 +0200 Subject: [PATCH 01/13] `TrivialTypeTraversalImpls!`: also impl `GenericTypeVisitable` When `TypeVisitable` is implemented but `GenericTypeVisitable` isn't, the lint (which we'll add soon) recommends adding `#[derive(GenericTypeVisitable)]`. However, this suggestion is incorrect for types whose impls ought to be trivial. There, the problem occurs because the type was added to `TrivialTypeTraversalImpls!` in `macros.rs`, which added the `TypeVisitable` impl, but wasn't added to `trivial_impls!` in `generic_visit.rs`, such that the `GenericTypeVisitable` impl wasn't added. Imo, the root cause of this problem is that we have two separate macros for adding trivial impls. So this commit merges them into one, by making `TrivialTypeTraversalImpls!` add a `GenericTypeVisitable` impl as well. RE: `Variance`: its `GenericTypeVisitable` impl is now provided by `TrivialTypeTraversalImpls!`, making the derive unnecessary. RE: `rustc_hash::FxBuildHasher`: its `GenericTypeVisitable` impl ended up being removed, because `TypeVisitable` can't be implemented due to it not implemnting `Debug`. This shouldn't be a problem however, as `{Generic,}TypeVisitable` should always be implemented in pairs anyway. I confirmed this by removing the impl from `ra-ap-rustc_type_ir` and `cargo check`-ing r-a. --- compiler/rustc_type_ir/src/generic_visit.rs | 47 --------------------- compiler/rustc_type_ir/src/lib.rs | 3 +- compiler/rustc_type_ir/src/macros.rs | 23 +++++++++- 3 files changed, 23 insertions(+), 50 deletions(-) diff --git a/compiler/rustc_type_ir/src/generic_visit.rs b/compiler/rustc_type_ir/src/generic_visit.rs index 2444990749411..9910c84b42d26 100644 --- a/compiler/rustc_type_ir/src/generic_visit.rs +++ b/compiler/rustc_type_ir/src/generic_visit.rs @@ -172,57 +172,10 @@ unsafe impl, S: GenericTypeVisitable> GenericTy } } -macro_rules! trivial_impls { - ( $($ty:ty),* $(,)? ) => { - $( - unsafe impl - GenericTypeVisitable for $ty - { - fn generic_visit_with(&self, _visitor: &mut V) {} - } - )* - }; -} - unsafe impl GenericTypeVisitable for std::marker::PhantomData { fn generic_visit_with(&self, _visitor: &mut V) {} } -trivial_impls!( - (), - rustc_ast_ir::Mutability, - bool, - i8, - i16, - i32, - i64, - i128, - isize, - u8, - u16, - u32, - u64, - u128, - usize, - crate::ClausePolarity, - crate::BoundConstness, - crate::DebruijnIndex, - crate::solve::Certainty, - crate::UniverseIndex, - crate::BoundVar, - crate::InferTy, - crate::IntTy, - crate::UintTy, - crate::FloatTy, - crate::InferConst, - crate::RegionVid, - rustc_hash::FxBuildHasher, - crate::TypeFlags, - crate::solve::GoalSource, - crate::solve::VisibleForLeakCheck, - rustc_abi::ExternAbi, -); - // SAFETY: `FnSigKind` is a packed representation, therefore visiting its fields doesn't make sense unsafe impl GenericTypeVisitable for crate::FnSigKind { fn generic_visit_with(&self, _visitor: &mut V) {} diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index b7fa0c77e44ee..38b717b2cadb4 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -105,7 +105,6 @@ pub use predicate::*; pub use predicate_kind::*; pub use region_kind::*; pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy}; -use rustc_type_ir_macros::GenericTypeVisitable; #[cfg(feature = "nightly")] pub use serialize::*; pub use sty::*; @@ -251,7 +250,7 @@ pub fn debug_bound_var( } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, GenericTypeVisitable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "nightly", derive(Decodable, Encodable, StableHash))] #[cfg_attr(feature = "nightly", rustc_pass_by_value)] pub enum Variance { diff --git a/compiler/rustc_type_ir/src/macros.rs b/compiler/rustc_type_ir/src/macros.rs index 3741c80d0eb14..096f43f81e608 100644 --- a/compiler/rustc_type_ir/src/macros.rs +++ b/compiler/rustc_type_ir/src/macros.rs @@ -31,6 +31,12 @@ macro_rules! TrivialTypeTraversalImpls { ::output() } } + + // NOTE: this deliberately avoids adding an `I: Interner` generic, because that would + // allow creating a trivial impl for arena-allocating types, which would be incorrect. + unsafe impl $crate::GenericTypeVisitable for $ty { + fn generic_visit_with(&self, _visitor: &mut V) {} + } )+ }; } @@ -44,21 +50,36 @@ macro_rules! TrivialTypeTraversalImpls { TrivialTypeTraversalImpls! { (), bool, - usize, + i8, + i16, + i32, + i64, + i128, + isize, u8, u16, u32, u64, + usize, // tidy-alphabetical-start crate::BoundConstness, + crate::BoundVar, crate::ClausePolarity, crate::DebruijnIndex, + crate::FloatTy, + crate::InferConst, + crate::InferTy, + crate::IntTy, + crate::RegionVid, + crate::TypeFlags, + crate::UintTy, crate::UniverseIndex, crate::Variance, crate::solve::BuiltinImplSource, crate::solve::Certainty, crate::solve::GoalSource, crate::solve::VisibleForLeakCheck, + rustc_abi::ExternAbi, rustc_ast_ir::Mutability, // tidy-alphabetical-end } From e3940510fa39613b20be1ccfea0d00a0cad07303 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Wed, 30 Sep 2026 13:11:01 +0200 Subject: [PATCH 02/13] dogfood: add missing `GenericTypeVisitable` impls The missing impl for arrays was (indirectly) highlighted by the test suite, the rest -- by the `#[deny]` --- compiler/rustc_type_ir/src/generic_visit.rs | 6 ++++++ compiler/rustc_type_ir/src/unnormalized.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_type_ir/src/generic_visit.rs b/compiler/rustc_type_ir/src/generic_visit.rs index 9910c84b42d26..e2663a61421f1 100644 --- a/compiler/rustc_type_ir/src/generic_visit.rs +++ b/compiler/rustc_type_ir/src/generic_visit.rs @@ -116,6 +116,12 @@ unsafe impl> GenericTypeVisitable for [T] { } } +unsafe impl, const N: usize> GenericTypeVisitable for [T; N] { + fn generic_visit_with(&self, visitor: &mut V) { + self.iter().for_each(|it| it.generic_visit_with(visitor)); + } +} + unsafe impl, Ix: Idx> GenericTypeVisitable for IndexVec { fn generic_visit_with(&self, visitor: &mut V) { self.iter().for_each(|it| it.generic_visit_with(visitor)); diff --git a/compiler/rustc_type_ir/src/unnormalized.rs b/compiler/rustc_type_ir/src/unnormalized.rs index 17a8e0e75fa78..3b03d64cd57a3 100644 --- a/compiler/rustc_type_ir/src/unnormalized.rs +++ b/compiler/rustc_type_ir/src/unnormalized.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use derive_where::derive_where; #[cfg(feature = "nightly")] use rustc_macros::StableHash_NoContext; -use rustc_type_ir_macros::TypeVisitable_Generic; +use rustc_type_ir_macros::{GenericTypeVisitable, TypeVisitable_Generic}; use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder}; use crate::inherent::*; @@ -30,7 +30,7 @@ use crate::{ /// [here]: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/Eager.20normalization.2C.20ahoy.21/with/582996293 #[derive_where(Clone, Copy, PartialOrd, PartialEq, Eq, Hash, Debug; T)] #[cfg_attr(feature = "nightly", derive(StableHash_NoContext))] -#[derive(TypeVisitable_Generic)] +#[derive(TypeVisitable_Generic, GenericTypeVisitable)] pub struct Unnormalized { value: T, #[type_visitable(ignore)] From bc6cee4b0c221c2accd7082af2d44025acc1c3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Oct 2026 01:58:19 +0000 Subject: [PATCH 03/13] Tweak `WellFormedLoc` Carry more information for well-formed obligations coming from expressions. --- .../rustc_hir_analysis/src/check/check.rs | 12 +-- .../rustc_hir_analysis/src/check/wfcheck.rs | 73 ++++++++++--------- .../rustc_hir_analysis/src/hir_wf_check.rs | 8 +- compiler/rustc_hir_typeck/src/callee.rs | 9 ++- compiler/rustc_hir_typeck/src/check.rs | 4 +- compiler/rustc_hir_typeck/src/expr.rs | 19 +++-- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 20 +++-- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 5 +- compiler/rustc_hir_typeck/src/lib.rs | 2 +- .../rustc_hir_typeck/src/method/confirm.rs | 5 +- compiler/rustc_middle/src/traits/mod.rs | 6 +- compiler/rustc_passes/src/layout_test.rs | 2 +- .../traits/fulfillment_errors.rs | 2 +- .../src/error_reporting/traits/suggestions.rs | 2 +- .../rustc_trait_selection/src/traits/wf.rs | 32 ++++---- 15 files changed, 117 insertions(+), 84 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 1e75902884fe1..76fd59577f248 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -964,8 +964,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { let ty = tcx.type_of(def_id).instantiate_identity(); let ty_span = tcx.ty_span(def_id); - let ty = wfcx.deeply_normalize(ty_span, Some(WellFormedLoc::Ty(def_id)), ty); - wfcx.register_wf_obligation(ty_span, Some(WellFormedLoc::Ty(def_id)), ty.into()); + let ty = wfcx.deeply_normalize(ty_span, WellFormedLoc::Ty(def_id), ty); + wfcx.register_wf_obligation(ty_span, WellFormedLoc::Ty(def_id), ty.into()); wfcx.register_bound( traits::ObligationCause::new( ty_span, @@ -993,12 +993,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), let span = tcx.def_span(def_id); if tcx.type_alias_is_checked(def_id) { res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { - let item_ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); - wfcx.register_wf_obligation( - span, - Some(WellFormedLoc::Ty(def_id)), - item_ty.into(), - ); + let item_ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(def_id), item_ty.into()); check_where_clauses(wfcx, def_id); Ok(()) })); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index dc4b6a6fd319c..adefd2b29ddf0 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -68,12 +68,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { // Convenience function to normalize during wfcheck. This performs // `ObligationCtxt::normalize`, but provides a nice `ObligationCauseCode`. - fn normalize( - &self, - span: Span, - loc: Option, - value: Unnormalized<'tcx, T>, - ) -> T + fn normalize(&self, span: Span, loc: WellFormedLoc, value: Unnormalized<'tcx, T>) -> T where T: TypeFoldable>, { @@ -96,7 +91,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { pub(super) fn deeply_normalize( &self, span: Span, - loc: Option, + loc: WellFormedLoc, value: Unnormalized<'tcx, T>, ) -> T where @@ -122,7 +117,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { pub(super) fn register_wf_obligation( &self, span: Span, - loc: Option, + loc: WellFormedLoc, term: ty::Term<'tcx>, ) { let cause = traits::ObligationCause::new( @@ -802,7 +797,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er if tcx.features().const_param_ty_unchecked() { enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| { - wfcx.register_wf_obligation(span, None, ty.into()); + wfcx.register_wf_obligation(span, WellFormedLoc::None, ty.into()); Ok(()) }) } else if tcx.features().adt_const_params() || tcx.features().min_adt_const_params() { @@ -916,7 +911,7 @@ pub(crate) fn check_associated_item( tcx: TyCtxt<'_>, def_id: LocalDefId, ) -> Result<(), ErrorGuaranteed> { - let loc = Some(WellFormedLoc::Ty(def_id)); + let loc = WellFormedLoc::Ty(def_id); enter_wf_checking_ctxt(tcx, def_id, |wfcx| { let item = tcx.associated_item(def_id); @@ -936,7 +931,7 @@ pub(crate) fn check_associated_item( match item.kind { ty::AssocKind::Const { .. } => { let ty = tcx.type_of(def_id).instantiate_identity(); - let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); + let ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty); wfcx.register_wf_obligation(span, loc, ty.into()); if item.defaultness(tcx).has_value() { @@ -964,7 +959,7 @@ pub(crate) fn check_associated_item( } if item.defaultness(tcx).has_value() { let ty = tcx.type_of(def_id).instantiate_identity(); - let ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), ty); + let ty = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), ty); wfcx.register_wf_obligation(span, loc, ty.into()); } Ok(()) @@ -1013,10 +1008,10 @@ pub(crate) fn check_type_defn<'tcx>( let span = tcx.ty_span(field_id); let ty = wfcx.deeply_normalize( span, - None, + WellFormedLoc::None, tcx.type_of(field.did).instantiate_identity(), ); - wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(field_id)), ty.into()); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(field_id), ty.into()); if matches!(ty.kind(), ty::Adt(def, _) if def.repr().scalable()) && !matches!(adt_def.repr().scalable, Some(ScalableElt::Container)) @@ -1051,7 +1046,11 @@ pub(crate) fn check_type_defn<'tcx>( { let last = idx == variant.fields.len() - 1; let span = tcx.ty_span(field.did.expect_local()); - let ty = wfcx.normalize(span, None, tcx.type_of(field.did).instantiate_identity()); + let ty = wfcx.normalize( + span, + WellFormedLoc::None, + tcx.type_of(field.did).instantiate_identity(), + ); wfcx.register_bound( traits::ObligationCause::new( span, @@ -1215,7 +1214,7 @@ pub(crate) fn check_static_item<'tcx>( } let span = tcx.ty_span(item_id); - let loc = Some(WellFormedLoc::Ty(item_id)); + let loc = WellFormedLoc::Ty(item_id); let item_ty = wfcx.deeply_normalize(span, loc, Unnormalized::new_wip(ty)); let is_foreign_item = tcx.is_foreign_item(item_id); @@ -1231,7 +1230,7 @@ pub(crate) fn check_static_item<'tcx>( }; let forbid_unsized = !(is_foreign_item && is_structurally_foreign_item()); - wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(item_id)), item_ty.into()); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(item_id), item_ty.into()); if forbid_unsized { let span = tcx.def_span(item_id); wfcx.register_bound( @@ -1300,12 +1299,16 @@ pub(super) fn check_const_item<'tcx>( if let Some(direct_rhs) = tcx.const_of_item(def_id) { let raw_ct = direct_rhs.instantiate_identity(); - let norm_ct = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(def_id)), raw_ct); - wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(def_id)), norm_ct.into()); + let norm_ct = wfcx.deeply_normalize(span, WellFormedLoc::Ty(def_id), raw_ct); + wfcx.register_wf_obligation(span, WellFormedLoc::Ty(def_id), norm_ct.into()); wfcx.register_obligation(Obligation::new( tcx, - ObligationCause::new(span, def_id, ObligationCauseCode::WellFormed(None)), + ObligationCause::new( + span, + def_id, + ObligationCauseCode::WellFormed(WellFormedLoc::Ty(def_id)), + ), wfcx.param_env, ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(norm_ct, item_ty)), )); @@ -1330,7 +1333,7 @@ fn check_impl<'tcx>( let trait_span = of_trait.trait_ref.path.span; let trait_ref = wfcx.deeply_normalize( trait_span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), trait_ref, ); let trait_pred = @@ -1367,7 +1370,7 @@ fn check_impl<'tcx>( { let bound = wfcx.normalize( item.span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), bound, ); wfcx.register_obligation(Obligation::new( @@ -1375,7 +1378,9 @@ fn check_impl<'tcx>( ObligationCause::new( impl_.self_ty.span, wfcx.body_def_id, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId( + of_trait.trait_ref.hir_ref_id, + )), ), wfcx.param_env, bound.to_host_effect_clause(tcx, ty::BoundConstness::Maybe), @@ -1390,12 +1395,12 @@ fn check_impl<'tcx>( let self_ty = tcx.type_of(item.owner_id).instantiate_identity().skip_norm_wip(); let self_ty = wfcx.deeply_normalize( item.span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), Unnormalized::new_wip(self_ty), ); wfcx.register_wf_obligation( impl_.self_ty.span, - Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)), + WellFormedLoc::Ty(item.hir_id().expect_owner().def_id), self_ty.into(), ); } @@ -1437,7 +1442,8 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: wfcx.register_wf_obligation( tcx.def_span(param.def_id), matches!(param.kind, GenericParamDefKind::Type { .. }) - .then(|| WellFormedLoc::Ty(param.def_id.expect_local())), + .then(|| WellFormedLoc::Ty(param.def_id.expect_local())) + .unwrap_or(WellFormedLoc::None), default.as_term().unwrap(), ); } else { @@ -1466,7 +1472,7 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: let cause = traits::ObligationCause::new( tcx.def_span(param.def_id), wfcx.body_def_id, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::Ty(def_id)), ); wfcx.register_obligation(Obligation::new( tcx, @@ -1560,7 +1566,7 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: // Note the subtle difference from how we handle `gen_clauses` // below: there, we are not trying to prove those clauses // to be *true* but merely *well-formed*. - let clause = wfcx.normalize(sp, None, clause); + let clause = wfcx.normalize(sp, WellFormedLoc::None, clause); let cause = traits::ObligationCause::new( sp, wfcx.body_def_id, @@ -1636,12 +1642,12 @@ fn check_fn_or_method<'tcx>( tcx.mk_type_list_from_iter(sig.inputs_and_output.iter().enumerate().map(|(idx, ty)| { wfcx.deeply_normalize( arg_span(idx), - Some(WellFormedLoc::Param { + WellFormedLoc::Param { function: def_id, // Note that the `param_idx` of the output type is // one greater than the index of the last input type. param_idx: idx, - }), + }, Unnormalized::new_wip(ty), ) })); @@ -1649,7 +1655,7 @@ fn check_fn_or_method<'tcx>( for (idx, ty) in sig.inputs_and_output.iter().enumerate() { wfcx.register_wf_obligation( arg_span(idx), - Some(WellFormedLoc::Param { function: def_id, param_idx: idx }), + WellFormedLoc::Param { function: def_id, param_idx: idx }, ty.into(), ); } @@ -1726,7 +1732,7 @@ fn check_method_receiver<'tcx>( } let span = fn_sig.decl.inputs[0].span; - let loc = Some(WellFormedLoc::Param { function: method.def_id.expect_local(), param_idx: 0 }); + let loc = WellFormedLoc::Param { function: method.def_id.expect_local(), param_idx: 0 }; let sig = tcx.fn_sig(method.def_id).instantiate_identity().skip_norm_wip(); let sig = tcx.liberate_late_bound_regions(method.def_id, sig); @@ -2319,7 +2325,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { // Match the existing behavior. if clause.is_global() && !clause.has_type_flags(TypeFlags::HAS_BINDER_VARS) { - let clause = self.normalize(span, None, Unnormalized::new_wip(clause)); + let clause = + self.normalize(span, WellFormedLoc::None, Unnormalized::new_wip(clause)); // only use the span of the predicate clause (#90869) let hir_node = tcx.hir_node_by_def_id(self.body_def_id); diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index 9b05789a28f49..9806b7b873918 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -19,7 +19,8 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( ) -> Option> { let def_id = match loc { WellFormedLoc::Ty(def_id) => def_id, - WellFormedLoc::Param { function, param_idx: _ } => function, + WellFormedLoc::Param { function, .. } => function, + WellFormedLoc::HirId(_) | WellFormedLoc::None => return None, }; let hir_id = tcx.local_def_id_to_hir_id(def_id); @@ -85,7 +86,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( let cause = traits::ObligationCause::new( ty.span, self.def_id, - traits::ObligationCauseCode::WellFormed(None), + traits::ObligationCauseCode::WellFormed(WellFormedLoc::HirId(ty.hir_id)), ); ocx.register_obligation(traits::Obligation::new( @@ -191,7 +192,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( } ref node => bug!("Unexpected node {:?}", node), }, - WellFormedLoc::Param { function: _, param_idx } => { + WellFormedLoc::Param { param_idx, .. } => { let fn_decl = tcx.hir_fn_decl_by_hir_id(hir_id).unwrap(); // Get return type if param_idx as usize == fn_decl.inputs.len() { @@ -204,6 +205,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>( vec![&fn_decl.inputs[param_idx as usize]] } } + WellFormedLoc::HirId(_) | WellFormedLoc::None => return None, }; for ty in tys { visitor.visit_ty_unambig(ty); diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 025c64896edb7..5ddbb3c502c98 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId}; use rustc_hir_analysis::autoderef::Autoderef; use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes}; -use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode}; +use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode, WellFormedLoc}; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, }; @@ -177,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( output.into(), call_expr.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)), ); output @@ -728,7 +728,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // now we have to unify it with signature input in order to resolve // all inference variables. After that we update input signature for // adjustments search for mapped arguments. - let cause = self.cause(call_expr.span, ObligationCauseCode::Misc); + let cause = self.cause( + call_expr.span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(call_expr.hir_id)), + ); if self .at(&cause, self.param_env) .sup(DefineOpaqueTypes::Yes, formal_input_tys[0], adjusted_arg_type) diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index b1b7aa5727097..8061e522f43aa 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -72,10 +72,10 @@ pub(super) fn check_fn<'a, 'tcx>( fcx.register_wf_obligation( param_ty.into(), param.span, - ObligationCauseCode::WellFormed(Some(WellFormedLoc::Param { + ObligationCauseCode::WellFormed(WellFormedLoc::Param { function: fn_def_id, param_idx: idx, - })), + }), ); } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 9f0d00d5274fa..ed39719b50000 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -25,6 +25,7 @@ use rustc_hir::{ExprKind, HirId, QPath, is_range_literal}; use rustc_hir_analysis::diagnostics::{NoFieldOnType, NoVariantNamed}; use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _; use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, RegionVariableOrigin}; +use rustc_infer::traits::WellFormedLoc; use rustc_infer::traits::query::NoSolution; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase}; use rustc_middle::ty::consts::ConstExt; @@ -699,14 +700,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized_deferred( output, call_expr_and_args.map_or(expr.span, |(e, _)| e.span), - ObligationCauseCode::SizedCallReturnType, + ObligationCauseCode::SizedCallReturnType(expr.hir_id), ); } // We always require that the type provided as the value for // a type parameter outlives the moment of instantiation. let args = self.typeck_results.borrow().node_args(expr.hir_id); - self.add_wf_bounds(args, expr.span); + self.add_wf_bounds(args, expr.span, expr.hir_id); ty } @@ -1772,7 +1773,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.deferred_repeat_expr_checks.borrow_mut().push((element, element_ty, count)); let ty = Ty::new_array_with_const_len(tcx, t, count); - self.register_wf_obligation(ty.into(), expr.span, ObligationCauseCode::WellFormed(None)); + self.register_wf_obligation( + ty.into(), + expr.span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(expr.hir_id)), + ); ty } @@ -1944,7 +1949,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( field_type.into(), field.expr.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(field.expr.hir_id)), ); // Make sure to give a type to the field even if there's @@ -3895,7 +3900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized( field_ty, expr.span, - ObligationCauseCode::Misc, + ObligationCauseCode::WellFormed(WellFormedLoc::None), ); } @@ -3924,7 +3929,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized( field_ty, expr.span, - ObligationCauseCode::Misc, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId( + expr.hir_id, + )), ); } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 1ad6225a8c467..b0f940dd7a21a 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -22,7 +22,7 @@ use rustc_hir_analysis::hir_ty_lowering::{ }; use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; use rustc_infer::infer::{DefineOpaqueTypes, InferResult}; -use rustc_infer::traits::TraitErrors; +use rustc_infer::traits::{TraitErrors, WellFormedLoc}; use rustc_lint_defs::builtin::{SELF_CONSTRUCTOR_FROM_OUTER_ITEM, UNREACHABLE_CODE}; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, DerefAdjustKind, @@ -543,7 +543,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn lower_ty(&self, hir_ty: &hir::Ty<'_>) -> LoweredTy<'tcx> { let ty = self.lowerer().lower_ty(hir_ty); - self.register_wf_obligation(ty.into(), hir_ty.span, ObligationCauseCode::WellFormed(None)); + self.register_wf_obligation( + ty.into(), + hir_ty.span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_ty.hir_id)), + ); LoweredTy::from_raw(self, hir_ty.span, ty) } @@ -608,7 +612,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( ct.into(), self.tcx.hir_span(const_arg.hir_id), - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(const_arg.hir_id)), ); ct } @@ -664,9 +668,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Registers obligations that all `args` are well-formed. - pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span) { + pub(crate) fn add_wf_bounds(&self, args: GenericArgsRef<'tcx>, span: Span, hir_id: HirId) { for term in args.iter().filter_map(ty::GenericArg::as_term) { - self.register_wf_obligation(term, span, ObligationCauseCode::WellFormed(None)); + self.register_wf_obligation( + term, + span, + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_id)), + ); } } @@ -810,7 +818,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( ty.raw.into(), qself.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_id)), ); self.select_obligations_where_possible(|_| {}); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 937182c2030da..8ecd7838a0e69 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -19,6 +19,7 @@ use rustc_index::IndexVec; use rustc_infer::infer::{ BoundRegionConversionTime, DefineOpaqueTypes, InferOk, TypeTrace, relate, }; +use rustc_infer::traits::WellFormedLoc; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::print::with_forced_trimmed_paths; @@ -230,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( fn_input_ty.into(), arg_expr.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(arg_expr.hir_id)), ); self.check_place_expr_if_unsized(fn_input_ty, arg_expr); @@ -1197,7 +1198,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_wf_obligation( decl_ty.into(), decl.pat.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(decl.pat.hir_id)), ); } self.overwrite_local_ty_if_err(decl.hir_id, decl.pat, pat_ty); diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 5efb2775c77fe..2945a6b3b5136 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -193,7 +193,7 @@ fn typeck_with_inspect<'tcx>( let expected_type = fcx.normalize(body.value.span, Unnormalized::new_wip(expected_type)); - let wf_code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))); + let wf_code = ObligationCauseCode::WellFormed(WellFormedLoc::Ty(def_id)); fcx.register_wf_obligation(expected_type.into(), body.value.span, wf_code); if let hir::Node::AnonConst(_) = node { diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 4518e419aea0f..721e9a38fc50c 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -13,6 +13,7 @@ use rustc_hir_analysis::hir_ty_lowering::{ use rustc_infer::infer::{ BoundRegionConversionTime, DefineOpaqueTypes, InferOk, RegionVariableOrigin, }; +use rustc_infer::traits::WellFormedLoc; use rustc_lint_defs::builtin::{ AMBIGUOUS_GLOB_IMPORTED_TRAITS, RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, }; @@ -648,7 +649,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // this is a projection from a trait reference, so we have to // make sure that the trait reference inputs are well-formed. - self.add_wf_bounds(all_args, self.call_expr.span); + self.add_wf_bounds(all_args, self.call_expr.span, self.call_expr.hir_id); // the function type must also be well-formed (this is not // implied by the args being well-formed because of inherent @@ -657,7 +658,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self.register_wf_obligation( ty.into(), self.span, - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(self.call_expr.hir_id)), ); } } diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 493f6989f342c..7c4c2d5aed157 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -238,7 +238,7 @@ pub enum ObligationCauseCode<'tcx> { /// Return type must be `Sized`. SizedReturnType, /// Return type of a call expression must be `Sized`. - SizedCallReturnType, + SizedCallReturnType(HirId), /// Yield type must be `Sized`. SizedYieldType, /// Inline asm operand type must be `Sized`. @@ -384,7 +384,7 @@ pub enum ObligationCauseCode<'tcx> { /// This is purely for diagnostic purposes - it is always /// correct to use `Misc` instead, or to specify /// `WellFormed(None)`. - WellFormed(Option), + WellFormed(WellFormedLoc), /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching /// against. @@ -461,6 +461,8 @@ pub enum WellFormedLoc { /// being the last 'parameter' param_idx: usize, }, + HirId(HirId), + None, } impl<'tcx> ObligationCauseCode<'tcx> { diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index 961d39ec8e5ca..31490a49b695c 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -41,7 +41,7 @@ pub fn ensure_wf<'tcx>( traits::ObligationCause::new( span, def_id, - traits::ObligationCauseCode::WellFormed(Some(traits::WellFormedLoc::Ty(def_id))), + traits::ObligationCauseCode::WellFormed(traits::WellFormedLoc::Ty(def_id)), ), param_env, pred, 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 3b21c5e5f19ba..30ca408226299 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 @@ -74,7 +74,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { SelectionError::Unimplemented => { // If this obligation was generated as a result of well-formedness checking, see if we // can get a better error message by performing HIR-based well-formedness checking. - if let ObligationCauseCode::WellFormed(Some(wf_loc)) = + if let ObligationCauseCode::WellFormed(wf_loc) = root_obligation.cause.code().peel_derives() && !obligation.predicate.has_non_region_infer() { 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 76755eb481db7..a2aae724228ba 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4325,7 +4325,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err.help("unsized fn params are gated as an unstable feature"); } } - ObligationCauseCode::SizedReturnType | ObligationCauseCode::SizedCallReturnType => { + ObligationCauseCode::SizedReturnType | ObligationCauseCode::SizedCallReturnType(_) => { err.note("the return type of a function must have a statically known size"); } ObligationCauseCode::SizedYieldType => { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index ba463184a41f8..41e6797e71d2d 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -7,7 +7,9 @@ use std::iter; use rustc_attr_ir::lang_items::LangItem; use rustc_hir as hir; -use rustc_infer::traits::{ObligationCauseCode, PredicateObligation, PredicateObligations}; +use rustc_infer::traits::{ + ObligationCauseCode, PredicateObligation, PredicateObligations, WellFormedLoc, +}; use rustc_middle::ty::{ self, DelayedSet, GenericArgsRef, PredicateProxy, Term, TermKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, @@ -352,7 +354,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { return self.out; } - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); let param_env = self.param_env; let mut obligations = PredicateObligations::with_capacity(self.out.len()); for mut obligation in self.out { @@ -519,7 +521,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { &mut traits::SelectionContext::new(self.infcx), self.param_env, data, - self.cause(ObligationCauseCode::WellFormed(None)), + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)), self.recursion_depth, &mut self.out, ); @@ -532,7 +534,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { fn add_wf_preds_for_projection_args(&mut self, args: GenericArgsRef<'tcx>) { let tcx = self.tcx(); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); let param_env = self.param_env; let depth = self.recursion_depth; @@ -976,7 +978,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let principal_def_id = principal.skip_binder().def_id; self.out.push(traits::Obligation::with_depth( tcx, - self.cause(ObligationCauseCode::WellFormed(None)), + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)), self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::DynCompatible(principal_def_id)), @@ -1044,7 +1046,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { if let Some(pred_binder) = pred_binder { self.out.push(traits::Obligation::with_depth( tcx, - self.cause(ObligationCauseCode::WellFormed(None)), + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)), self.recursion_depth, self.param_env, pred_binder, @@ -1067,7 +1069,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { // See also the comment on `fn obligations`, describing cycle // prevention, which happens before this can be reached. ty::Infer(_) => { - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, cause, @@ -1094,7 +1096,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(c), )); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, cause, @@ -1128,7 +1131,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } } ty::ConstKind::Infer(_) => { - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, @@ -1151,7 +1154,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(c), )); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.push(traits::Obligation::with_depth( tcx, cause, @@ -1174,7 +1177,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { ty::Adt(adt_def, args) => { let adt_val = val.destructure_adt_const(); let variant_def = adt_def.variant(adt_val.variant); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.extend(variant_def.fields.iter().zip(adt_val.fields).map( |(field_def, &field_val)| { let field_ty = tcx @@ -1196,7 +1200,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } ty::Tuple(field_tys) => { let field_vals = val.to_branch(); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.extend(field_tys.iter().zip(field_vals).map( |(field_ty, &field_val)| { let predicate = ty::PredicateKind::Clause( @@ -1214,7 +1219,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } ty::Array(elem_ty, _len) => { let elem_vals = val.to_branch(); - let cause = self.cause(ObligationCauseCode::WellFormed(None)); + let cause = + self.cause(ObligationCauseCode::WellFormed(WellFormedLoc::None)); self.out.extend(elem_vals.iter().map(|&elem_val| { let predicate = ty::PredicateKind::Clause( From 9083df37d3849a2e904d140221ffd7245a0b635c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Oct 2026 02:05:48 +0000 Subject: [PATCH 04/13] Add tests for 84346 and 105753 fix fmt --- tests/ui/sized/unsized-inference.rs | 10 +++++ tests/ui/sized/unsized-inference.stderr | 42 +++++++++++++++++++ tests/ui/sized/unsized-return-type-in-call.rs | 13 ++++++ .../sized/unsized-return-type-in-call.stderr | 40 ++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 tests/ui/sized/unsized-inference.rs create mode 100644 tests/ui/sized/unsized-inference.stderr create mode 100644 tests/ui/sized/unsized-return-type-in-call.rs create mode 100644 tests/ui/sized/unsized-return-type-in-call.stderr diff --git a/tests/ui/sized/unsized-inference.rs b/tests/ui/sized/unsized-inference.rs new file mode 100644 index 0000000000000..6f5eb314a640f --- /dev/null +++ b/tests/ui/sized/unsized-inference.rs @@ -0,0 +1,10 @@ +// Issue #84346. +use std::fmt::Display; + +fn main() { + let x = vec![1, 2, 3]; + let y: Vec = x.into_iter().collect(); + //~^ ERROR: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + //~| ERROR: a value of type `Vec` cannot be built from an iterator over elements of type `{integer}` + //~| ERROR: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time +} diff --git a/tests/ui/sized/unsized-inference.stderr b/tests/ui/sized/unsized-inference.stderr new file mode 100644 index 0000000000000..f44aaa1e72a4d --- /dev/null +++ b/tests/ui/sized/unsized-inference.stderr @@ -0,0 +1,42 @@ +error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + --> $DIR/unsized-inference.rs:6:12 + | +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: a value of type `Vec` cannot be built from an iterator over elements of type `{integer}` + --> $DIR/unsized-inference.rs:6:45 + | +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^ value of type `Vec` cannot be built from `std::iter::Iterator` + | + = help: the trait `FromIterator<{integer}>` is not implemented for `Vec` +help: the trait `FromIterator` is implemented for `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL +note: the method call chain might not have had the expected associated types + --> $DIR/unsized-inference.rs:6:33 + | +LL | let x = vec![1, 2, 3]; + | ------------- this expression has type `Vec<{integer}>` +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^^^^^ `Iterator::Item` is `{integer}` here +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + --> $DIR/unsized-inference.rs:6:31 + | +LL | let y: Vec = x.into_iter().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/sized/unsized-return-type-in-call.rs b/tests/ui/sized/unsized-return-type-in-call.rs new file mode 100644 index 0000000000000..1cee44bd24954 --- /dev/null +++ b/tests/ui/sized/unsized-return-type-in-call.rs @@ -0,0 +1,13 @@ +// Issue #105753. +trait T {} + +fn foo() -> dyn T { + //~^ ERROR: return type cannot be a trait object without pointer indirection + todo!() +} + +fn main() { + let x = foo(); + //~^ ERROR: the size for values of type `dyn T` cannot be known at compilation time + //~| ERROR: the size for values of type `(dyn T + 'static)` cannot be known at compilation time +} diff --git a/tests/ui/sized/unsized-return-type-in-call.stderr b/tests/ui/sized/unsized-return-type-in-call.stderr new file mode 100644 index 0000000000000..ae6efaca93ce9 --- /dev/null +++ b/tests/ui/sized/unsized-return-type-in-call.stderr @@ -0,0 +1,40 @@ +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/unsized-return-type-in-call.rs:4:13 + | +LL | fn foo() -> dyn T { + | ^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn foo() -> dyn T { +LL + fn foo() -> impl T { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn foo() -> Box { +LL | +LL ~ Box::new(todo!()) + | + +error[E0277]: the size for values of type `dyn T` cannot be known at compilation time + --> $DIR/unsized-return-type-in-call.rs:10:9 + | +LL | let x = foo(); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn T` + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time + --> $DIR/unsized-return-type-in-call.rs:10:13 + | +LL | let x = foo(); + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn T + 'static)` + = note: the return type of a function must have a statically known size + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0746. +For more information about an error, try `rustc --explain E0277`. From 55d1925a7ef0e2f21401e0e7b863be9d4970a23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Oct 2026 02:38:27 +0000 Subject: [PATCH 05/13] Silence redundant failed obligations on the same statement Reduces the number of errors being emitted by a single unmet `Sized` (or other) bound in method call chains. --- compiler/rustc_infer/src/infer/at.rs | 2 + compiler/rustc_infer/src/infer/mod.rs | 6 ++ .../traits/fulfillment_errors.rs | 59 ++++++++++++++++++- .../associated-const-in-trait.rs | 1 - .../associated-const-in-trait.stderr | 18 +----- .../hr-associated-type-bound-object.rs | 2 - .../hr-associated-type-bound-object.stderr | 38 +----------- .../hr-associated-type-bound-param-2.rs | 2 - .../hr-associated-type-bound-param-2.stderr | 38 +----------- .../async-future-out-must-be-sized.rs | 1 - .../async-future-out-must-be-sized.stderr | 15 +---- tests/ui/box/into-boxed-slice-fail.rs | 2 - tests/ui/box/into-boxed-slice-fail.stderr | 22 +------ ...ized-return-suggest-ref-issue-152064.fixed | 18 ------ ...unsized-return-suggest-ref-issue-152064.rs | 3 - ...zed-return-suggest-ref-issue-152064.stderr | 38 ++---------- .../const_kind_expr/issue_114151.rs | 10 ++-- .../cross_crate_predicate.rs | 2 - .../cross_crate_predicate.stderr | 31 +--------- .../dependence_lint.full.stderr | 6 +- .../dependence_lint.gce.stderr | 19 ++---- .../generic_const_exprs/dependence_lint.rs | 3 +- .../assoc_type_bounds_sized_used.rs | 2 - .../assoc_type_bounds_sized_used.stderr | 54 +---------------- tests/ui/iterators/collect-into-slice.rs | 3 - tests/ui/iterators/collect-into-slice.stderr | 14 +---- ...ter-macro-not-async-closure.current.stderr | 40 +------------ .../iterators/iter-macro-not-async-closure.rs | 5 +- .../methods/bad-wf-when-selecting-method.rs | 1 - .../bad-wf-when-selecting-method.stderr | 18 +----- tests/ui/sized/unsized-inference.rs | 1 - tests/ui/sized/unsized-inference.stderr | 12 +--- tests/ui/sized/unsized-return-type-in-call.rs | 1 - .../sized/unsized-return-type-in-call.stderr | 11 +--- .../ice-missing-field-fn-sig-closure.rs | 5 +- .../ice-missing-field-fn-sig-closure.stderr | 19 +----- tests/ui/structs/ice-missing-field-fn-sig.rs | 3 +- .../structs/ice-missing-field-fn-sig.stderr | 19 +----- .../suggestions/mut-borrow-needed-by-trait.rs | 1 - .../mut-borrow-needed-by-trait.stderr | 16 +---- .../negated-auto-traits-error.rs | 1 - .../negated-auto-traits-error.stderr | 37 ++++-------- ...-capture-uninferred-upvars-issue-162440.rs | 1 - ...ture-uninferred-upvars-issue-162440.stderr | 21 +------ ...-capture-uninferred-upvars-with-capture.rs | 1 - ...ture-uninferred-upvars-with-capture.stderr | 29 ++------- ...paque-hidden-in-closure-sig.current.stderr | 40 +------------ ...ied-bounds-opaque-hidden-in-closure-sig.rs | 2 - .../leak-infer-ice-120254.next.stderr | 26 ++------ .../leak-infer-ice-120254.rs | 2 - 50 files changed, 132 insertions(+), 589 deletions(-) delete mode 100644 tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 341ea9a70dbc7..6a34bd4884d73 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -78,6 +78,7 @@ impl<'tcx> InferCtxt<'tcx> { selection_cache: self.selection_cache.clone(), evaluation_cache: self.evaluation_cache.clone(), reported_trait_errors: self.reported_trait_errors.clone(), + reported_hir_errors: self.reported_hir_errors.clone(), reported_signature_mismatch: self.reported_signature_mismatch.clone(), tainted_by_errors: self.tainted_by_errors.clone(), universe: self.universe.clone(), @@ -108,6 +109,7 @@ impl<'tcx> InferCtxt<'tcx> { selection_cache: Default::default(), evaluation_cache: Default::default(), reported_trait_errors: self.reported_trait_errors.clone(), + reported_hir_errors: self.reported_hir_errors.clone(), reported_signature_mismatch: self.reported_signature_mismatch.clone(), tainted_by_errors: self.tainted_by_errors.clone(), universe: self.universe.clone(), diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index a7ce6a4353b59..c45c5e44aaa31 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -307,6 +307,11 @@ pub struct InferCtxt<'tcx> { pub reported_trait_errors: RefCell>>, ErrorGuaranteed)>>, + /// A set of predicates *on a specific* HIR node (the originating expression and its enclosing + /// statement), to avoid reporting multiple errors pointing at different sub-expressions in the + /// same method chain. + pub reported_hir_errors: RefCell>>>, + pub reported_signature_mismatch: RefCell)>>, /// When an error occurs, we want to avoid reporting "derived" @@ -689,6 +694,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { selection_cache: Default::default(), evaluation_cache: Default::default(), reported_trait_errors: Default::default(), + reported_hir_errors: Default::default(), reported_signature_mismatch: Default::default(), tainted_by_errors: Cell::new(None), universe: Cell::new(ty::UniverseIndex::ROOT), 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 30ca408226299..1614899ece03d 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 @@ -21,7 +21,7 @@ use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, Node, expr_needs_parens}; use rustc_infer::infer::{InferOk, TypeTrace}; use rustc_infer::traits::solve::Goal; -use rustc_infer::traits::{ImplSource, TraitErrors}; +use rustc_infer::traits::{ImplSource, TraitErrors, WellFormedLoc}; use rustc_middle::traits::SignatureMismatchData; use rustc_middle::traits::select::OverflowError; use rustc_middle::ty::abstract_const::NotConstEvaluatable; @@ -77,6 +77,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { if let ObligationCauseCode::WellFormed(wf_loc) = root_obligation.cause.code().peel_derives() && !obligation.predicate.has_non_region_infer() + && !matches!(wf_loc, WellFormedLoc::None) { if let Some(cause) = self.tcx.diagnostic_hir_wf_check(( tcx.erase_and_anonymize_regions(obligation.predicate), @@ -831,6 +832,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; self.note_obligation_cause(&mut err, &obligation); + self.silence_redundant_cause(&mut err, &obligation, &root_obligation); err.emit_err() } } @@ -3083,6 +3085,61 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } + /// Register when multiple obligations come from the same statement and only emit one. + /// + /// This can significantly reduce the number of `_: Sized` failures on method chains. + fn silence_redundant_cause( + &self, + err: &mut Diag<'_>, + obligation: &PredicateObligation<'tcx>, + root_obligation: &PredicateObligation<'tcx>, + ) { + let hir_id = match root_obligation.cause.code() { + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(hir_id)) + | ObligationCauseCode::VariableType(hir_id) + | ObligationCauseCode::WhereClauseInExpr(_, _, hir_id, _) + | ObligationCauseCode::SizedCallReturnType(hir_id) => *hir_id, + ObligationCauseCode::WellFormed(WellFormedLoc::Param { function, .. }) => { + self.tcx.local_def_id_to_hir_id(*function) + } + _ => return, + }; + + // The lifetimes for different sub-expressions would be different inference variables. + let pred = self.tcx.erase_and_anonymize_regions(obligation.predicate); + + // Registering the expression itself is necessary to catch tail expressions and literals. + if let Some(preds) = self.reported_hir_errors.borrow().get(&hir_id) + && preds.contains(&pred) + { + err.downgrade_to_delayed_bug(); + } else { + self.reported_hir_errors.borrow_mut().entry(hir_id).or_default().insert(pred); + } + + // Look for the expression's parent statement, bail otherwise. We'll register the predicate + // against the statement's HirId. + for (_, node) in self.tcx.hir_parent_iter(hir_id) { + let hir_id = match node { + hir::Node::LetStmt(stmt) => stmt.hir_id, + hir::Node::Stmt(stmt) => stmt.hir_id, + hir::Node::Crate(_) + | hir::Node::Item(_) + | hir::Node::ImplItem(_) + | hir::Node::TraitItem(_) => break, + _ => continue, + }; + if let Some(preds) = self.reported_hir_errors.borrow().get(&hir_id) + && preds.contains(&pred) + { + err.downgrade_to_delayed_bug(); + } else { + self.reported_hir_errors.borrow_mut().entry(hir_id).or_default().insert(pred); + } + break; + } + } + pub fn note_obligation_cause( &self, err: &mut Diag<'_>, diff --git a/tests/ui/associated-consts/associated-const-in-trait.rs b/tests/ui/associated-consts/associated-const-in-trait.rs index da68a0fa97c82..90ad596b23ee1 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.rs +++ b/tests/ui/associated-consts/associated-const-in-trait.rs @@ -8,7 +8,6 @@ impl dyn Trait { //~^ ERROR the trait `Trait` is not dyn compatible [E0038] const fn n() -> usize { Self::N } //~^ ERROR the trait `Trait` is not dyn compatible [E0038] - //~| ERROR the trait `Trait` is not dyn compatible [E0038] } fn main() {} diff --git a/tests/ui/associated-consts/associated-const-in-trait.stderr b/tests/ui/associated-consts/associated-const-in-trait.stderr index 4085f8c990785..64ac88856fdc4 100644 --- a/tests/ui/associated-consts/associated-const-in-trait.stderr +++ b/tests/ui/associated-consts/associated-const-in-trait.stderr @@ -30,22 +30,6 @@ LL | const N: usize; | ^ ...because it contains associated const `N` = help: consider moving `N` to another trait -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/associated-const-in-trait.rs:9:29 - | -LL | const fn n() -> usize { Self::N } - | ^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/associated-const-in-trait.rs:4:11 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | const N: usize; - | ^ ...because it contains associated const `N` - = help: consider moving `N` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/associated-types/hr-associated-type-bound-object.rs b/tests/ui/associated-types/hr-associated-type-bound-object.rs index 825e129dbbda1..62ed7c7edfe79 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-object.rs +++ b/tests/ui/associated-types/hr-associated-type-bound-object.rs @@ -8,8 +8,6 @@ fn f<'a, T: X<'a> + ?Sized>(x: &>::U) { //~^ ERROR the trait bound `for<'b> >::U: Clone` is not satisfied <>::U>::clone(x); //~^ ERROR the trait bound `for<'b> >::U: Clone` is not satisfied - //~| ERROR the trait bound `for<'b> >::U: Clone` is not satisfied - //~| ERROR the trait bound `for<'b> >::U: Clone` is not satisfied //~| ERROR the trait bound `>::U: Clone` is not satisfied } diff --git a/tests/ui/associated-types/hr-associated-type-bound-object.stderr b/tests/ui/associated-types/hr-associated-type-bound-object.stderr index d1563c923bc7a..0a6831ad8801b 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-object.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-object.stderr @@ -48,42 +48,6 @@ help: consider further restricting the associated type LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where >::U: Clone { | ++++++++++++++++++++++++++++ -error[E0277]: the trait bound `for<'b> >::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-object.rs:9:5 - | -LL | <>::U>::clone(x); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `>::U` - | -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-object.rs:3:33 - | -LL | trait X<'a> -LL | where -LL | for<'b> >::U: Clone, - | ^^^^^ required by this bound in `X` -help: consider further restricting the associated type - | -LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where for<'b> >::U: Clone { - | ++++++++++++++++++++++++++++++++++++ - -error[E0277]: the trait bound `for<'b> >::U: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-object.rs:9:5 - | -LL | <>::U>::clone(x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `>::U` - | -note: required by a bound in `X` - --> $DIR/hr-associated-type-bound-object.rs:3:33 - | -LL | trait X<'a> -LL | where -LL | for<'b> >::U: Clone, - | ^^^^^ required by this bound in `X` -help: consider further restricting the associated type - | -LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where for<'b> >::U: Clone { - | ++++++++++++++++++++++++++++++++++++ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-2.rs b/tests/ui/associated-types/hr-associated-type-bound-param-2.rs index d6546c24dc50b..7e40cec345f7e 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-2.rs +++ b/tests/ui/associated-types/hr-associated-type-bound-param-2.rs @@ -9,8 +9,6 @@ where fn h(&self, x: &T::W) { ::clone(x); //~^ ERROR the trait bound `str: Clone` is not satisfied - //~| ERROR the trait bound `str: Clone` is not satisfied - //~| ERROR the trait bound `str: Clone` is not satisfied } } diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr index f025798750a58..b1a7e8ac4062a 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr @@ -15,7 +15,7 @@ LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:18:14 + --> $DIR/hr-associated-type-bound-param-2.rs:16:14 | LL | type W = str; | ^^^ the trait `Clone` is not implemented for `str` @@ -67,39 +67,7 @@ LL | type W: ?Sized; | error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:10:9 - | -LL | ::clone(x); - | ^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` - | -help: the trait `Clone` is implemented for `String` - --> $SRC_DIR/alloc/src/string.rs:LL:COL -note: required by a bound in `Z` - --> $DIR/hr-associated-type-bound-param-2.rs:6:35 - | -LL | trait Z<'a, T: ?Sized> -... -LL | for<'b> >::W: Clone, - | ^^^^^ required by this bound in `Z` - -error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:10:9 - | -LL | ::clone(x); - | ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str` - | -help: the trait `Clone` is implemented for `String` - --> $SRC_DIR/alloc/src/string.rs:LL:COL -note: required by a bound in `Z` - --> $DIR/hr-associated-type-bound-param-2.rs:6:35 - | -LL | trait Z<'a, T: ?Sized> -... -LL | for<'b> >::W: Clone, - | ^^^^^ required by this bound in `Z` - -error[E0277]: the trait bound `str: Clone` is not satisfied - --> $DIR/hr-associated-type-bound-param-2.rs:23:10 + --> $DIR/hr-associated-type-bound-param-2.rs:21:10 | LL | 1u16.h("abc"); | ^ the trait `Clone` is not implemented for `str` @@ -117,6 +85,6 @@ LL | for<'b> >::W: Clone, LL | fn h(&self, x: &T::W) { | -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs index e5d70e30eb5f6..2daed6b09dcc9 100644 --- a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs +++ b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs @@ -16,5 +16,4 @@ async fn is_async_fn(f: impl AsyncFn()) { fn main() { is_async_fn(foo()); //~^ ERROR the size for values of type `dyn Future` cannot be known at compilation time - //~| ERROR the size for values of type `dyn Future` cannot be known at compilation time } diff --git a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr index f993247d8b90a..1168a854f5d32 100644 --- a/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr +++ b/tests/ui/async-await/async-closures/async-future-out-must-be-sized.stderr @@ -13,19 +13,6 @@ note: required by a bound in `is_async_fn` LL | async fn is_async_fn(f: impl AsyncFn()) { | ^^^^^^^^^ required by this bound in `is_async_fn` -error[E0277]: the size for values of type `dyn Future` cannot be known at compilation time - --> $DIR/async-future-out-must-be-sized.rs:17:5 - | -LL | is_async_fn(foo()); - | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Future` -note: required by a bound in `is_async_fn` - --> $DIR/async-future-out-must-be-sized.rs:12:30 - | -LL | async fn is_async_fn(f: impl AsyncFn()) { - | ^^^^^^^^^ required by this bound in `is_async_fn` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/box/into-boxed-slice-fail.rs b/tests/ui/box/into-boxed-slice-fail.rs index 49dbb170f8e78..db2e5623264e6 100644 --- a/tests/ui/box/into-boxed-slice-fail.rs +++ b/tests/ui/box/into-boxed-slice-fail.rs @@ -6,9 +6,7 @@ fn main() { let boxed_slice = Box::new([1,2,3]) as Box<[u8]>; let _ = Box::into_boxed_slice(boxed_slice); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~^^ ERROR the size for values of type `[u8]` cannot be known at compilation time let boxed_trait: Box = Box::new(5u8); let _ = Box::into_boxed_slice(boxed_trait); //~^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time - //~^^ ERROR the size for values of type `dyn Debug` cannot be known at compilation time } diff --git a/tests/ui/box/into-boxed-slice-fail.stderr b/tests/ui/box/into-boxed-slice-fail.stderr index f102f666dc276..a66fa533c6f02 100644 --- a/tests/ui/box/into-boxed-slice-fail.stderr +++ b/tests/ui/box/into-boxed-slice-fail.stderr @@ -10,17 +10,8 @@ LL | let _ = Box::into_boxed_slice(boxed_slice); note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/into-boxed-slice-fail.rs:7:13 - | -LL | let _ = Box::into_boxed_slice(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: slice and array elements must have `Sized` type - error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/into-boxed-slice-fail.rs:11:35 + --> $DIR/into-boxed-slice-fail.rs:10:35 | LL | let _ = Box::into_boxed_slice(boxed_trait); | --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time @@ -31,15 +22,6 @@ LL | let _ = Box::into_boxed_slice(boxed_trait); note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL -error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/into-boxed-slice-fail.rs:11:13 - | -LL | let _ = Box::into_boxed_slice(boxed_trait); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Debug` - = note: slice and array elements must have `Sized` type - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed deleted file mode 100644 index 2e1d10fb2804c..0000000000000 --- a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.fixed +++ /dev/null @@ -1,18 +0,0 @@ -#![allow(unused_variables, for_loops_over_fallibles)] -//@ run-rustfix - -fn main() { - // Basic case from the issue: str slice - let o = Some("Hello, world!"); - for s in o.map(|s| &s[3..8]) {} - //~^ ERROR the size for values of type `str` cannot be known at compilation time - //~| ERROR the size for values of type `str` cannot be known at compilation time - //~| ERROR `Option` is not an iterator - - // Byte slice case - let arr = Some(b"Hello, world!"); - for s in arr.map(|s| &s[3..8]) {} - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| ERROR `Option<[u8]>` is not an iterator -} diff --git a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs index 6a0573248ff8b..f88bf3c908685 100644 --- a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs +++ b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.rs @@ -1,18 +1,15 @@ #![allow(unused_variables, for_loops_over_fallibles)] -//@ run-rustfix fn main() { // Basic case from the issue: str slice let o = Some("Hello, world!"); for s in o.map(|s| s[3..8]) {} //~^ ERROR the size for values of type `str` cannot be known at compilation time - //~| ERROR the size for values of type `str` cannot be known at compilation time //~| ERROR `Option` is not an iterator // Byte slice case let arr = Some(b"Hello, world!"); for s in arr.map(|s| s[3..8]) {} //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time - //~| ERROR the size for values of type `[u8]` cannot be known at compilation time //~| ERROR `Option<[u8]>` is not an iterator } diff --git a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr index c5e5e71cd8823..de08baa48461a 100644 --- a/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr +++ b/tests/ui/closures/unsized-return-suggest-ref-issue-152064.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:7:16 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:6:16 | LL | for s in o.map(|s| s[3..8]) {} | ^^^ doesn't have a size known at compile-time @@ -8,22 +8,8 @@ LL | for s in o.map(|s| s[3..8]) {} note: required by an implicit `Sized` bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:7:14 - | -LL | for s in o.map(|s| s[3..8]) {} - | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by an implicit `Sized` bound in `Option` - --> $SRC_DIR/core/src/option.rs:LL:COL -help: consider borrowing the value - | -LL | for s in o.map(|s| &s[3..8]) {} - | + - error[E0277]: `Option` is not an iterator - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:7:14 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:6:14 | LL | for s in o.map(|s| s[3..8]) {} | ^^^^^^^^^^^^^^^^^^ `Option` is not an iterator @@ -41,7 +27,7 @@ help: the following other types implement trait `IntoIterator` = note: `&mut Option` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:14:18 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:12:18 | LL | for s in arr.map(|s| s[3..8]) {} | ^^^ doesn't have a size known at compile-time @@ -50,22 +36,8 @@ LL | for s in arr.map(|s| s[3..8]) {} note: required by an implicit `Sized` bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:14:14 - | -LL | for s in arr.map(|s| s[3..8]) {} - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` -note: required by an implicit `Sized` bound in `Option` - --> $SRC_DIR/core/src/option.rs:LL:COL -help: consider borrowing the value - | -LL | for s in arr.map(|s| &s[3..8]) {} - | + - error[E0277]: `Option<[u8]>` is not an iterator - --> $DIR/unsized-return-suggest-ref-issue-152064.rs:14:14 + --> $DIR/unsized-return-suggest-ref-issue-152064.rs:12:14 | LL | for s in arr.map(|s| s[3..8]) {} | ^^^^^^^^^^^^^^^^^^^^ `Option<[u8]>` is not an iterator @@ -82,6 +54,6 @@ help: the following other types implement trait `IntoIterator` | = note: `&mut Option` -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs index e575d0dc9b405..58936f3e741ec 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs @@ -16,11 +16,11 @@ where { foo::<_, L>([(); L + 1 + L]); //~^ ERROR: mismatched types - //~^^ ERROR: unconstrained generic constant - //~^^^ ERROR: function takes 1 generic argument but 2 generic arguments were supplied - //~^^^^ ERROR: unconstrained generic constant - //~^^^^^ ERROR: unconstrained generic constant `L + 1 + L` - //~^^^^^^ ERROR: unconstrained generic constant `L + 1` + //~| ERROR: unconstrained generic constant + //~| ERROR: function takes 1 generic argument but 2 generic arguments were supplied + //~| ERROR: unconstrained generic constant + //~| ERROR: unconstrained generic constant `L + 1 + L` + //~| ERROR: unconstrained generic constant `L + 1` } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs index 304c176e85ae9..083c3bf47aad7 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs @@ -7,8 +7,6 @@ fn user() { let _ = const_evaluatable_lib::test1::(); //~^ ERROR unconstrained generic constant //~| ERROR unconstrained generic constant - //~| ERROR unconstrained generic constant - //~| ERROR unconstrained generic constant } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 5c2d9d22c48f0..c45509656ab36 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -32,34 +32,5 @@ help: try adding a `where` bound LL | fn user() where [(); std::mem::size_of::() - 1]: { | +++++++++++++++++++++++++++++++++++++++++ -error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 - | -LL | let _ = const_evaluatable_lib::test1::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try adding a `where` bound - | -LL | fn user() where [(); std::mem::size_of::() - 1]: { - | +++++++++++++++++++++++++++++++++++++++++ - -error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 - | -LL | let _ = const_evaluatable_lib::test1::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: required by a bound in `test1` - --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10 - | -LL | pub fn test1() -> [u8; std::mem::size_of::() - 1] -LL | where -LL | [u8; std::mem::size_of::() - 1]: Sized, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` -help: try adding a `where` bound - | -LL | fn user() where [(); std::mem::size_of::() - 1]: { - | +++++++++++++++++++++++++++++++++++++++++ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr index 810a87c35aed8..05c8f1e945ccc 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.full.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:15:32 + --> $DIR/dependence_lint.rs:14:32 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -9,7 +9,7 @@ LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce = help: alternatively, you can use `#![feature(gca_const_items)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/dependence_lint.rs:22:37 + --> $DIR/dependence_lint.rs:21:37 | LL | let _: [u8; if true { size_of::() } else { 3 }]; // error on stable, error with gce | ^ cannot perform const operation using `T` @@ -29,7 +29,7 @@ LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_ = note: `#[warn(const_evaluatable_unchecked)]` (part of `#[warn(future_incompatible)]`) on by default warning: cannot use constants which depend on generic parameters in types - --> $DIR/dependence_lint.rs:18:9 + --> $DIR/dependence_lint.rs:17:9 | LL | [0; if false { size_of::() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr index 12ac980c97544..f6119c17bf47e 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr @@ -9,19 +9,8 @@ help: try adding a `where` bound LL | fn foo() where [(); size_of::<*mut T>()]: { | ++++++++++++++++++++++++++++++++ -error: unconstrained generic constant - --> $DIR/dependence_lint.rs:10:5 - | -LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try adding a `where` bound - | -LL | fn foo() where [(); size_of::<*mut T>()]: { - | ++++++++++++++++++++++++++++++++ - error: overly complex generic constant - --> $DIR/dependence_lint.rs:18:9 + --> $DIR/dependence_lint.rs:17:9 | LL | [0; if false { size_of::() } else { 3 }]; // lint on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants @@ -29,7 +18,7 @@ LL | [0; if false { size_of::() } else { 3 }]; // lint on stable, error w = help: consider moving this anonymous constant into a `const` function error: unconstrained generic constant - --> $DIR/dependence_lint.rs:15:12 + --> $DIR/dependence_lint.rs:14:12 | LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,12 +29,12 @@ LL | fn foo() where [(); size_of::<*mut T>()]: { | ++++++++++++++++++++++++++++++++ error: overly complex generic constant - --> $DIR/dependence_lint.rs:22:17 + --> $DIR/dependence_lint.rs:21:17 | LL | let _: [u8; if true { size_of::() } else { 3 }]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ control flow is not supported in generic constants | = help: consider moving this anonymous constant into a `const` function -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs b/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs index 6b3c8f84be3d1..107466cd1d9ca 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.rs @@ -9,8 +9,7 @@ use std::mem::size_of; fn foo() { [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` //[gce]~^ ERROR unconstrained - //[gce]~| ERROR unconstrained generic constant - //[full]~^^^ WARNING cannot use constants + //[full]~^^ WARNING cannot use constants //[full]~| WARNING this was previously accepted let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce //[full]~^ ERROR generic parameters may not be used diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs index 8243803c86d70..80c2863418929 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.rs @@ -10,8 +10,6 @@ trait Bop { fn bop() { let _ = ::Bar::default(); //~^ ERROR: the size for values of type `T` cannot be known at compilation time - //~| ERROR: the size for values of type `T` cannot be known at compilation time - //~| ERROR: the size for values of type `T` cannot be known at compilation time } fn main() { diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr index 26f00fc72f868..9eb4e5bf5ef05 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr @@ -24,58 +24,6 @@ help: consider relaxing the implicit `Sized` restriction LL | type Bar: Default + ?Sized | ++++++++ -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:11:13 - | -LL | fn bop() { - | - this type parameter needs to be `Sized` -LL | let _ = ::Bar::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -note: required by a bound in `Bop::Bar` - --> $DIR/assoc_type_bounds_sized_used.rs:7:15 - | -LL | trait Bop { -LL | type Bar: Default -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bop::Bar` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn bop() { -LL + fn bop() { - | -help: consider relaxing the implicit `Sized` restriction - | -LL | type Bar: Default + ?Sized - | ++++++++ - -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/assoc_type_bounds_sized_used.rs:11:13 - | -LL | fn bop() { - | - this type parameter needs to be `Sized` -LL | let _ = ::Bar::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -note: required by a bound in `Bop::Bar` - --> $DIR/assoc_type_bounds_sized_used.rs:7:15 - | -LL | trait Bop { -LL | type Bar: Default -LL | where -LL | Self: Sized; - | ^^^^^ required by this bound in `Bop::Bar` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn bop() { -LL + fn bop() { - | -help: consider relaxing the implicit `Sized` restriction - | -LL | type Bar: Default + ?Sized - | ++++++++ - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/collect-into-slice.rs b/tests/ui/iterators/collect-into-slice.rs index c90cfa4e90d3a..462110d788106 100644 --- a/tests/ui/iterators/collect-into-slice.rs +++ b/tests/ui/iterators/collect-into-slice.rs @@ -6,14 +6,11 @@ fn main() { let some_generated_vec = (0..10).collect(); //~^ ERROR the size for values of type `[i32]` cannot be known at compilation time //~| NOTE required by a bound introduced by this call - //~| ERROR the size for values of type `[i32]` cannot be known at compilation time //~| ERROR a slice of type `[i32]` cannot be built since `[i32]` has no definite size //~| NOTE try explicitly collecting into a `Vec<{integer}>` - //~| NOTE required by an implicit `Sized` bound in `collect` //~| NOTE required by a bound in `collect` //~| NOTE all local variables must have a statically known size //~| NOTE doesn't have a size known at compile-time - //~| NOTE doesn't have a size known at compile-time process_slice(&some_generated_vec); let some_generated_vec = (0..10).collect(); diff --git a/tests/ui/iterators/collect-into-slice.stderr b/tests/ui/iterators/collect-into-slice.stderr index b5444a71cc177..f910bae958240 100644 --- a/tests/ui/iterators/collect-into-slice.stderr +++ b/tests/ui/iterators/collect-into-slice.stderr @@ -19,18 +19,8 @@ LL | let some_generated_vec = (0..10).collect(); = help: the trait `Sized` is not implemented for `[i32]` = note: all local variables must have a statically known size -error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/collect-into-slice.rs:6:38 - | -LL | let some_generated_vec = (0..10).collect(); - | ^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[i32]` -note: required by an implicit `Sized` bound in `collect` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - error[E0277]: a slice of type `&[i32]` cannot be built since we need to store the elements somewhere - --> $DIR/collect-into-slice.rs:19:31 + --> $DIR/collect-into-slice.rs:16:31 | LL | let some_generated_vec = (0..10).collect(); | ^^^^^ ------- required by a bound introduced by this call @@ -41,6 +31,6 @@ LL | let some_generated_vec = (0..10).collect(); note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure.current.stderr b/tests/ui/iterators/iter-macro-not-async-closure.current.stderr index c896d226a7715..ca20bbf4e3150 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.current.stderr +++ b/tests/ui/iterators/iter-macro-not-async-closure.current.stderr @@ -12,42 +12,6 @@ note: required by a bound in `call_async_once` LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:31:18 - | -LL | let x = pin!(call_async_once(f)); - | ^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` - | -note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 - | -LL | async fn call_async_once(f: impl AsyncFnOnce()) { - | ^^^^^^^^^^^^^ required by this bound in `call_async_once` - -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:31:13 - | -LL | let x = pin!(call_async_once(f)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` - | -note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 - | -LL | async fn call_async_once(f: impl AsyncFnOnce()) { - | ^^^^^^^^^^^^^ required by this bound in `call_async_once` - -error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:31:13 - | -LL | let x = pin!(call_async_once(f)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` - | -note: required by a bound in `call_async_once` - --> $DIR/iter-macro-not-async-closure.rs:20:34 - | -LL | async fn call_async_once(f: impl AsyncFnOnce()) { - | ^^^^^^^^^^^^^ required by this bound in `call_async_once` - error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied --> $DIR/iter-macro-not-async-closure.rs:31:13 | @@ -61,7 +25,7 @@ LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` error[E0277]: the trait bound `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}: AsyncFnOnce()` is not satisfied - --> $DIR/iter-macro-not-async-closure.rs:37:5 + --> $DIR/iter-macro-not-async-closure.rs:34:5 | LL | x.poll(&mut Context::from_waker(Waker::noop())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncFnOnce()` is not implemented for `{gen closure@$DIR/iter-macro-not-async-closure.rs:25:21: 25:28}` @@ -72,6 +36,6 @@ note: required by a bound in `call_async_once` LL | async fn call_async_once(f: impl AsyncFnOnce()) { | ^^^^^^^^^^^^^ required by this bound in `call_async_once` -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/iterators/iter-macro-not-async-closure.rs b/tests/ui/iterators/iter-macro-not-async-closure.rs index 3cf9e2237d2e7..1736423065396 100644 --- a/tests/ui/iterators/iter-macro-not-async-closure.rs +++ b/tests/ui/iterators/iter-macro-not-async-closure.rs @@ -30,10 +30,7 @@ fn main() { let x = pin!(call_async_once(f)); //[current]~^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^^^ ERROR AsyncFnOnce()` is not satisfied - //[current]~^^^^^ ERROR AsyncFnOnce()` is not satisfied + //[current]~| ERROR AsyncFnOnce()` is not satisfied x.poll(&mut Context::from_waker(Waker::noop())); //[current]~^ ERROR AsyncFnOnce()` is not satisfied } diff --git a/tests/ui/methods/bad-wf-when-selecting-method.rs b/tests/ui/methods/bad-wf-when-selecting-method.rs index 1f1a10f420462..c54ab963c2cfa 100644 --- a/tests/ui/methods/bad-wf-when-selecting-method.rs +++ b/tests/ui/methods/bad-wf-when-selecting-method.rs @@ -11,7 +11,6 @@ trait Trait { fn test(t: T) { Wrapper(t).needs_sized(); //~^ ERROR the trait bound `T: Wf` is not satisfied - //~| ERROR the trait bound `T: Wf` is not satisfied //~| ERROR the method `needs_sized` exists for struct `Wrapper`, but its trait bounds were not satisfied } diff --git a/tests/ui/methods/bad-wf-when-selecting-method.stderr b/tests/ui/methods/bad-wf-when-selecting-method.stderr index e6d500349670c..7a8a1fe3ab546 100644 --- a/tests/ui/methods/bad-wf-when-selecting-method.stderr +++ b/tests/ui/methods/bad-wf-when-selecting-method.stderr @@ -16,22 +16,6 @@ help: consider restricting type parameter `T` with trait `Wf` LL | fn test(t: T) { | ++++ -error[E0277]: the trait bound `T: Wf` is not satisfied - --> $DIR/bad-wf-when-selecting-method.rs:12:5 - | -LL | Wrapper(t).needs_sized(); - | ^^^^^^^^^^ the trait `Wf` is not implemented for `T` - | -note: required by a bound in `Wrapper` - --> $DIR/bad-wf-when-selecting-method.rs:5:19 - | -LL | struct Wrapper, U>(T); - | ^^^^^^^^^^^^^ required by this bound in `Wrapper` -help: consider restricting type parameter `T` with trait `Wf` - | -LL | fn test(t: T) { - | ++++ - error[E0599]: the method `needs_sized` exists for struct `Wrapper`, but its trait bounds were not satisfied --> $DIR/bad-wf-when-selecting-method.rs:12:16 | @@ -48,7 +32,7 @@ help: consider restricting the type parameter to satisfy the trait bound LL | fn test(t: T) where T: Wf { | +++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/sized/unsized-inference.rs b/tests/ui/sized/unsized-inference.rs index 6f5eb314a640f..1484b1f2d80ba 100644 --- a/tests/ui/sized/unsized-inference.rs +++ b/tests/ui/sized/unsized-inference.rs @@ -6,5 +6,4 @@ fn main() { let y: Vec = x.into_iter().collect(); //~^ ERROR: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time //~| ERROR: a value of type `Vec` cannot be built from an iterator over elements of type `{integer}` - //~| ERROR: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time } diff --git a/tests/ui/sized/unsized-inference.stderr b/tests/ui/sized/unsized-inference.stderr index f44aaa1e72a4d..dd8873430cee3 100644 --- a/tests/ui/sized/unsized-inference.stderr +++ b/tests/ui/sized/unsized-inference.stderr @@ -27,16 +27,6 @@ LL | let y: Vec = x.into_iter().collect(); note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time - --> $DIR/unsized-inference.rs:6:31 - | -LL | let y: Vec = x.into_iter().collect(); - | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` -note: required by an implicit `Sized` bound in `Vec` - --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/sized/unsized-return-type-in-call.rs b/tests/ui/sized/unsized-return-type-in-call.rs index 1cee44bd24954..a3ea0fd3c244e 100644 --- a/tests/ui/sized/unsized-return-type-in-call.rs +++ b/tests/ui/sized/unsized-return-type-in-call.rs @@ -9,5 +9,4 @@ fn foo() -> dyn T { fn main() { let x = foo(); //~^ ERROR: the size for values of type `dyn T` cannot be known at compilation time - //~| ERROR: the size for values of type `(dyn T + 'static)` cannot be known at compilation time } diff --git a/tests/ui/sized/unsized-return-type-in-call.stderr b/tests/ui/sized/unsized-return-type-in-call.stderr index ae6efaca93ce9..8fad01645d84b 100644 --- a/tests/ui/sized/unsized-return-type-in-call.stderr +++ b/tests/ui/sized/unsized-return-type-in-call.stderr @@ -25,16 +25,7 @@ LL | let x = foo(); = help: the trait `Sized` is not implemented for `dyn T` = note: all local variables must have a statically known size -error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time - --> $DIR/unsized-return-type-in-call.rs:10:13 - | -LL | let x = foo(); - | ^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn T + 'static)` - = note: the return type of a function must have a statically known size - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0746. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/structs/ice-missing-field-fn-sig-closure.rs b/tests/ui/structs/ice-missing-field-fn-sig-closure.rs index 6878dd85ff847..dde3fba2e5a46 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig-closure.rs +++ b/tests/ui/structs/ice-missing-field-fn-sig-closure.rs @@ -10,7 +10,6 @@ fn main() { let c = |_: Wrapper<()>| {}; //~ ERROR the trait bound `(): Context` is not satisfied c(Wrapper { /* missing */ }); //~^ ERROR the trait bound `(): Context` is not satisfied - //~^^ ERROR missing field `container` in initializer of `Wrapper<_>` - //~^^^ ERROR the trait bound `(): Context` is not satisfied - //~^^^^ ERROR the trait bound `(): Context` is not satisfied + //~| ERROR missing field `container` in initializer of `Wrapper<_>` + //~| ERROR the trait bound `(): Context` is not satisfied } diff --git a/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr b/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr index 8e5b2fa931e4f..67048b657f17f 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr +++ b/tests/ui/structs/ice-missing-field-fn-sig-closure.stderr @@ -38,23 +38,6 @@ error[E0063]: missing field `container` in initializer of `Wrapper<_>` LL | c(Wrapper { /* missing */ }); | ^^^^^^^ missing `container` -error[E0277]: the trait bound `(): Context` is not satisfied - --> $DIR/ice-missing-field-fn-sig-closure.rs:11:7 - | -LL | c(Wrapper { /* missing */ }); - | ^^^^^^^ the trait `Context` is not implemented for `()` - | -help: this trait has no implementations, consider adding one - --> $DIR/ice-missing-field-fn-sig-closure.rs:4:1 - | -LL | trait Context {} - | ^^^^^^^^^^^^^ -note: required by a bound in `Wrapper` - --> $DIR/ice-missing-field-fn-sig-closure.rs:5:19 - | -LL | struct Wrapper { - | ^^^^^^^ required by this bound in `Wrapper` - error[E0277]: the trait bound `(): Context` is not satisfied --> $DIR/ice-missing-field-fn-sig-closure.rs:11:5 | @@ -72,7 +55,7 @@ note: required by a bound in `Wrapper` LL | struct Wrapper { | ^^^^^^^ required by this bound in `Wrapper` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0063, E0277. For more information about an error, try `rustc --explain E0063`. diff --git a/tests/ui/structs/ice-missing-field-fn-sig.rs b/tests/ui/structs/ice-missing-field-fn-sig.rs index 9ba48f6a6e795..41467d91449e8 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig.rs +++ b/tests/ui/structs/ice-missing-field-fn-sig.rs @@ -7,8 +7,7 @@ struct Wrapper { fn foobar(_: Wrapper<()>) { //~ ERROR the trait bound `(): Context` is not satisfied foobar(Wrapper { /* missing */ }) //~^ ERROR the trait bound `(): Context` is not satisfied -//~^^ ERROR missing field `container` in initializer of `Wrapper<_>` -//~^^^ ERROR the trait bound `(): Context` is not satisfied +//~| ERROR missing field `container` in initializer of `Wrapper<_>` } fn main() {} diff --git a/tests/ui/structs/ice-missing-field-fn-sig.stderr b/tests/ui/structs/ice-missing-field-fn-sig.stderr index 7be7886b2d975..5d8ed5bbf5eb5 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig.stderr +++ b/tests/ui/structs/ice-missing-field-fn-sig.stderr @@ -38,24 +38,7 @@ error[E0063]: missing field `container` in initializer of `Wrapper<_>` LL | foobar(Wrapper { /* missing */ }) | ^^^^^^^ missing `container` -error[E0277]: the trait bound `(): Context` is not satisfied - --> $DIR/ice-missing-field-fn-sig.rs:8:12 - | -LL | foobar(Wrapper { /* missing */ }) - | ^^^^^^^ the trait `Context` is not implemented for `()` - | -help: this trait has no implementations, consider adding one - --> $DIR/ice-missing-field-fn-sig.rs:3:1 - | -LL | trait Context {} - | ^^^^^^^^^^^^^ -note: required by a bound in `Wrapper` - --> $DIR/ice-missing-field-fn-sig.rs:4:19 - | -LL | struct Wrapper { - | ^^^^^^^ required by this bound in `Wrapper` - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0063, E0277. For more information about an error, try `rustc --explain E0063`. diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.rs b/tests/ui/suggestions/mut-borrow-needed-by-trait.rs index 66e1e77c905e0..1686a7dddb137 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.rs +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.rs @@ -16,7 +16,6 @@ fn main() { let fp = BufWriter::new(fp); //~^ ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied - //~| ERROR the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied writeln!(fp, "hello world").unwrap(); //~ ERROR the method } diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr index 5ba7fcb2479bb..6b2d315c96aac 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -10,24 +10,14 @@ LL | let fp = BufWriter::new(fp); note: required by a bound in `BufWriter::::new` --> $SRC_DIR/alloc/src/io/buffered/bufwriter.rs:LL:COL -error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied - --> $DIR/mut-borrow-needed-by-trait.rs:17:14 - | -LL | let fp = BufWriter::new(fp); - | ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` - | - = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` -note: required by a bound in `BufWriter` - --> $SRC_DIR/alloc/src/io/buffered/bufwriter.rs:LL:COL - error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn std::io::Write>`, but its trait bounds were not satisfied - --> $DIR/mut-borrow-needed-by-trait.rs:21:14 + --> $DIR/mut-borrow-needed-by-trait.rs:20:14 | LL | writeln!(fp, "hello world").unwrap(); | ---------^^---------------- method cannot be called on `BufWriter<&dyn std::io::Write>` due to unsatisfied trait bounds | note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method - --> $DIR/mut-borrow-needed-by-trait.rs:21:14 + --> $DIR/mut-borrow-needed-by-trait.rs:20:14 | LL | writeln!(fp, "hello world").unwrap(); | ^^ @@ -35,7 +25,7 @@ LL | writeln!(fp, "hello world").unwrap(); `&dyn std::io::Write: std::io::Write` which is required by `BufWriter<&dyn std::io::Write>: std::io::Write` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.rs b/tests/ui/traits/negative-impls/negated-auto-traits-error.rs index 4bdad5dc591c5..523876c9f2a4f 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.rs +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.rs @@ -22,7 +22,6 @@ fn dummy() { Outer(TestType); //~^ ERROR `dummy::TestType` cannot be sent between threads safely - //~| ERROR `dummy::TestType` cannot be sent between threads safely } fn dummy1b() { diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index 64e9dae2633b8..60b6c712341c7 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -17,25 +17,8 @@ note: required by a bound in `Outer` LL | struct Outer(T); | ^^^^ required by this bound in `Outer` -error[E0277]: `dummy::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:23:5 - | -LL | Outer(TestType); - | ^^^^^^^^^^^^^^^ `dummy::TestType` cannot be sent between threads safely - | -help: the trait `Send` is not implemented for `dummy::TestType` - --> $DIR/negated-auto-traits-error.rs:20:5 - | -LL | struct TestType; - | ^^^^^^^^^^^^^^^ -note: required by a bound in `Outer` - --> $DIR/negated-auto-traits-error.rs:10:17 - | -LL | struct Outer(T); - | ^^^^ required by this bound in `Outer` - error[E0277]: `dummy1b::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:32:13 + --> $DIR/negated-auto-traits-error.rs:31:13 | LL | is_send(TestType); | ------- ^^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely @@ -43,7 +26,7 @@ LL | is_send(TestType); | required by a bound introduced by this call | help: the trait `Send` is not implemented for `dummy1b::TestType` - --> $DIR/negated-auto-traits-error.rs:29:5 + --> $DIR/negated-auto-traits-error.rs:28:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -54,7 +37,7 @@ LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error[E0277]: `dummy1c::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:40:13 + --> $DIR/negated-auto-traits-error.rs:39:13 | LL | is_send((8, TestType)); | ------- ^^^^^^^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely @@ -62,7 +45,7 @@ LL | is_send((8, TestType)); | required by a bound introduced by this call | help: within `({integer}, dummy1c::TestType)`, the trait `Send` is not implemented for `dummy1c::TestType` - --> $DIR/negated-auto-traits-error.rs:37:5 + --> $DIR/negated-auto-traits-error.rs:36:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -74,7 +57,7 @@ LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error[E0277]: `dummy2::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:48:13 + --> $DIR/negated-auto-traits-error.rs:47:13 | LL | is_send(Box::new(TestType)); | ------- ^^^^^^^^^^^^^^^^^^ the trait `Send` is not implemented for `std::ptr::Unique` @@ -96,7 +79,7 @@ LL | is_send(&Box::new(TestType)); | + error[E0277]: `dummy3::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:56:13 + --> $DIR/negated-auto-traits-error.rs:55:13 | LL | is_send(Box::new(Outer2(TestType))); | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely @@ -104,7 +87,7 @@ LL | is_send(Box::new(Outer2(TestType))); | required by a bound introduced by this call | help: within `Outer2`, the trait `Send` is not implemented for `dummy3::TestType` - --> $DIR/negated-auto-traits-error.rs:53:5 + --> $DIR/negated-auto-traits-error.rs:52:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -123,7 +106,7 @@ LL | fn is_send(_: T) {} | ^^^^ required by this bound in `is_send` error[E0277]: `main::TestType` cannot be sent between threads safely - --> $DIR/negated-auto-traits-error.rs:66:20 + --> $DIR/negated-auto-traits-error.rs:65:20 | LL | is_sync(Outer2(TestType)); | ------- ^^^^^^^^ `main::TestType` cannot be sent between threads safely @@ -131,7 +114,7 @@ LL | is_sync(Outer2(TestType)); | required by a bound introduced by this call | help: the trait `Send` is not implemented for `main::TestType` - --> $DIR/negated-auto-traits-error.rs:61:5 + --> $DIR/negated-auto-traits-error.rs:60:5 | LL | struct TestType; | ^^^^^^^^^^^^^^^ @@ -148,6 +131,6 @@ note: required by a bound in `is_sync` LL | fn is_sync(_: T) {} | ^^^^ required by this bound in `is_sync` -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs index 9b6562ff578bf..1cd0445289fbb 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.rs @@ -8,5 +8,4 @@ fn main() { Some([0]).map(|s| s[..]); //~^ ERROR the size for values of type `[{integer}]` cannot be known at compilation time //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time - //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time } diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr index 4aed7e179b8ef..40338cf23f004 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-issue-162440.stderr @@ -17,25 +17,6 @@ LL | Some([0]).map(|s| s[..]); = help: the trait `Sized` is not implemented for `[{integer}]` = note: the return type of a function must have a statically known size -error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time - --> $DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19 - | -LL | Some([0]).map(|s| s[..]); - | --- ---^^^^^^ - | | | - | | doesn't have a size known at compile-time - | | within this `{closure@$DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19: 8:22}` - | required by a bound introduced by this call - | - = help: within `{closure@$DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19: 8:22}`, the trait `Sized` is not implemented for `[{integer}]` -note: required because it's used within this closure - --> $DIR/closure-capture-uninferred-upvars-issue-162440.rs:8:19 - | -LL | Some([0]).map(|s| s[..]); - | ^^^ -note: required by a bound in `Option::::map` - --> $SRC_DIR/core/src/option.rs:LL:COL - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs index ff4a9b67a3fee..62c6884a321ce 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.rs @@ -8,7 +8,6 @@ fn main() { Some([0]).map(|s| { //~^ ERROR the size for values of type `[{integer}]` cannot be known at compilation time - //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time //~| ERROR the size for values of type `[{integer}]` cannot be known at compilation time let _ = &x; s[..] diff --git a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr index b19dca701f2fb..05a3a44504246 100644 --- a/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr +++ b/tests/ui/traits/next-solver/closure-capture-uninferred-upvars-with-capture.stderr @@ -13,7 +13,9 @@ error[E0277]: the size for values of type `[{integer}]` cannot be known at compi | LL | Some([0]).map(|s| { | _______________________^ -... | +LL | | +LL | | +LL | | let _ = &x; LL | | s[..] LL | | }); | |_____^ doesn't have a size known at compile-time @@ -21,29 +23,6 @@ LL | | }); = help: the trait `Sized` is not implemented for `[{integer}]` = note: the return type of a function must have a statically known size -error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time - --> $DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19 - | -LL | Some([0]).map(|s| { - | --- ^-- - | | | - | _______________|___within this `{closure@$DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19: 9:22}` - | | | - | | required by a bound introduced by this call -... | -LL | | s[..] -LL | | }); - | |_____^ doesn't have a size known at compile-time - | - = help: within `{closure@$DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19: 9:22}`, the trait `Sized` is not implemented for `[{integer}]` -note: required because it's used within this closure - --> $DIR/closure-capture-uninferred-upvars-with-capture.rs:9:19 - | -LL | Some([0]).map(|s| { - | ^^^ -note: required by a bound in `Option::::map` - --> $SRC_DIR/core/src/option.rs:LL:COL - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr index 1189f62601759..15516922d9276 100644 --- a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr +++ b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr @@ -19,44 +19,6 @@ LL | struct RequiresWf(F) LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` -error[E0277]: the trait bound `impl Sized: Trait` is not satisfied - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:35:14 - | -LL | (|_| ())(RequiresWf(opaque)); - | ^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized` - | -help: the trait `Trait` is implemented for `()` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:17:1 - | -LL | impl Trait for () { - | ^^^^^^^^^^^^^^^^^ -note: required by a bound in `RequiresWf` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 - | -LL | struct RequiresWf(F) -... -LL | F::Output: Trait, - | ^^^^^ required by this bound in `RequiresWf` - -error[E0277]: the trait bound `impl Sized: Trait` is not satisfied - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:35:7 - | -LL | (|_| ())(RequiresWf(opaque)); - | ^ the trait `Trait` is not implemented for `impl Sized` - | -help: the trait `Trait` is implemented for `()` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:17:1 - | -LL | impl Trait for () { - | ^^^^^^^^^^^^^^^^^ -note: required by a bound in `RequiresWf` - --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 - | -LL | struct RequiresWf(F) -... -LL | F::Output: Trait, - | ^^^^^ required by this bound in `RequiresWf` - error[E0277]: the trait bound `impl Sized: Trait` is not satisfied --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:35:5 | @@ -76,6 +38,6 @@ LL | struct RequiresWf(F) LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs index 6fe74f0d4f9d3..324c99b5bab92 100644 --- a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs +++ b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.rs @@ -35,8 +35,6 @@ fn opaque() -> impl Sized { (|_| ())(RequiresWf(opaque)); //[current]~^ ERROR the trait bound `impl Sized: Trait` is not satisfied //[current]~| ERROR the trait bound `impl Sized: Trait` is not satisfied - //[current]~| ERROR the trait bound `impl Sized: Trait` is not satisfied - //[current]~| ERROR the trait bound `impl Sized: Trait` is not satisfied } fn main() {} diff --git a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr index 39deff902a1a0..b96467228aa8d 100644 --- a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr +++ b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.next.stderr @@ -1,25 +1,11 @@ error[E0277]: the trait bound `E: Dbg` is not satisfied - --> $DIR/leak-infer-ice-120254.rs:33:28 + --> $DIR/leak-infer-ice-120254.rs:31:28 | LL | fn record_err(self, _: ::Checkpoint) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Dbg` is not implemented for `E` | note: required for `Foo` to implement `Bar` - --> $DIR/leak-infer-ice-120254.rs:24:22 - | -LL | impl Bar for Foo { - | --- ^^^ ^^^^^^^^^ - | | - | unsatisfied trait bound introduced here -help: consider restricting type parameter `E` with trait `Dbg` - | -LL | impl Foo { - | +++++ - -error[E0277]: the trait bound `E: Dbg` is not satisfied - | -note: required for `Foo` to implement `Bar` - --> $DIR/leak-infer-ice-120254.rs:24:22 + --> $DIR/leak-infer-ice-120254.rs:22:22 | LL | impl Bar for Foo { | --- ^^^ ^^^^^^^^^ @@ -31,19 +17,19 @@ LL | impl Foo { | +++++ error: the type ` as Bar>::Checkpoint` is not well-formed - --> $DIR/leak-infer-ice-120254.rs:33:28 + --> $DIR/leak-infer-ice-120254.rs:31:28 | LL | fn record_err(self, _: ::Checkpoint) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `E: Dbg` is not satisfied - --> $DIR/leak-infer-ice-120254.rs:33:28 + --> $DIR/leak-infer-ice-120254.rs:31:28 | LL | fn record_err(self, _: ::Checkpoint) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Dbg` is not implemented for `E` | note: required for `Foo` to implement `Bar` - --> $DIR/leak-infer-ice-120254.rs:24:22 + --> $DIR/leak-infer-ice-120254.rs:22:22 | LL | impl Bar for Foo { | --- ^^^ ^^^^^^^^^ @@ -55,6 +41,6 @@ help: consider restricting type parameter `E` with trait `Dbg` LL | impl Foo { | +++++ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs index 0299381e17312..ccf1ed3d9826f 100644 --- a/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs +++ b/tests/ui/type-inference/snapshot-infer-leakage/leak-infer-ice-120254.rs @@ -5,8 +5,6 @@ //@[old] dont-check-compiler-stderr //@[old] known-bug: #120254 -//[next]~^^^^^^^ ERROR: the trait bound `E: Dbg` is not satisfied - // Regression test for #120254. This no longer reproduces with the new solver // even though the underlying issue has not been fixed. From 9d0888f264ed311af8627155439444a255235816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Oct 2026 15:23:00 +0000 Subject: [PATCH 06/13] Use `WellFormedLoc::HirId` for `offset_of!` `Sized` obligation cause code --- compiler/rustc_hir_typeck/src/expr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index ed39719b50000..a301cb6a397d9 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -3900,7 +3900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.require_type_is_sized( field_ty, expr.span, - ObligationCauseCode::WellFormed(WellFormedLoc::None), + ObligationCauseCode::WellFormed(WellFormedLoc::HirId(expr.hir_id)), ); } From df42c7b1bb4febef37de6c9e4381a28961f2ad3e Mon Sep 17 00:00:00 2001 From: dianne Date: Tue, 6 Oct 2026 12:17:54 -0700 Subject: [PATCH 07/13] elide potentially-problematic projection clauses --- .../src/traits/dyn_compatibility.rs | 9 ++- ...ity-placeholder-does-not-satisfy-bounds.rs | 24 ++++++ ...placeholder-does-not-satisfy-bounds.stderr | 11 +++ ...tchability-placeholder-satisfies-bounds.rs | 75 +++++++++++++++++-- 4 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs create mode 100644 tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index 1d57fd9e4b285..0cc886a2c1909 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -749,14 +749,19 @@ fn receiver_is_dispatchable<'tcx>( let trait_predicate = ty::TraitRef::new_from_args(tcx, trait_def_id, args); clauses.push(trait_predicate.upcast(tcx)); - // U satisfies `Trait`'s where-bounds. + // U satisfies Trait's trait bounds. When normalizing `U: Trait`, aliases + // in the arguments of supertrait bounds can generate trait obligations which may only be + // be provable using where-clauses from Trait (#161621). clauses.extend( tcx.clauses_of(trait_def_id) .instantiate(tcx, args) .clauses .into_iter() - .map(Unnormalized::skip_norm_wip), + .map(Unnormalized::skip_norm_wip) + .filter(|clause| matches!(clause.kind().skip_binder(), ty::ClauseKind::Trait(_))), ); + // FIXME(@dianne): we need projection clauses too in some form, but adding them all + // unmodified can introduce ambiguity (#163550) let meta_sized_predicate = { let meta_sized_did = tcx.require_lang_item(LangItem::MetaSized, DUMMY_SP); diff --git a/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs new file mode 100644 index 0000000000000..c899c66056839 --- /dev/null +++ b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.rs @@ -0,0 +1,24 @@ +//! Tests for specific instances of that don't +//! pass yet. See `dispatchability-placeholder-satisfies-bounds.rs` for context. +// FIXME(@dianne): this should be gone soon +//@ known-bug: unknown + +trait HasAssoc { + type Assoc; +} + +trait Parent {} + +trait NotDynCompatible +where + // We need to be able to normalize this for RustaceansAreAwesome in order to prove + // `<(RustaceansAreAwesome,) as HasAssoc>::Assoc: Owned` for the projection in the argument to + // the `Self: Parent<...>` supertrait bound. Currently a projection clause for it is missing + // from the `ParamEnv`. + (Self,): HasAssoc, + Self: Parent<<<(Self,) as HasAssoc>::Assoc as ToOwned>::Owned>, +{ + fn f(&self); +} + +fn main() {} diff --git a/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr new file mode 100644 index 0000000000000..3b2b8c62e8994 --- /dev/null +++ b/tests/ui/dyn-compatibility/dispatchability-placeholder-does-not-satisfy-bounds.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `<(RustaceansAreAwesome,) as HasAssoc>::Assoc: Clone` is not satisfied + --> $DIR/dispatchability-placeholder-does-not-satisfy-bounds.rs:21:5 + | +LL | fn f(&self); + | ^^^^^^^^^^^^ the trait `Clone` is not implemented for `<(RustaceansAreAwesome,) as HasAssoc>::Assoc` + | + = note: required for `<(RustaceansAreAwesome,) as HasAssoc>::Assoc` to implement `ToOwned` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs b/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs index 421b9a512c1e4..611e1cb59d4ab 100644 --- a/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs +++ b/tests/ui/dyn-compatibility/dispatchability-placeholder-satisfies-bounds.rs @@ -1,11 +1,15 @@ -//! Regression tests for . When checking whether -//! method receivers for a trait `Trait` are dynamically dispatchable, we use a placeholder type in -//! place of `dyn Trait` to avoid a cycle (as that would require determining whether `Trait` is dyn- -//! compatible). This placeholder must satisfy `Trait`'s where-bounds to avoid errors in param- -//! environment normalization. +//! Regression tests for and similar. When +//! checking whether method receivers for a trait `Trait` are dynamically dispatchable, we (at the +//! time of writing) use a placeholder type called `RustaceansAreAwesome` in place of `dyn Trait` to +//! avoid a cycle (as using `dyn Trait` requires determining whether `Trait` is dyn-compatible). We +//! assume that `RustaceansAreAwesome` implements `Trait`, so when normalizing the param-environment +//! we construct, we may have to prove obligations for aliases encountered in arguments to super- +//! trait bounds. It's possible for these to only be provable using clauses from `Trait` or its +//! supertraits that would be necessary for `RustaceansAreAwesome` to implement `Trait`. //@ check-pass -// Test 1 +// This works for `Self: Super<...Ty::::Assoc...>` after the `where`. +// We need to assume `(Args, RustaceansAreAwesome::Output): SignatureToFnPtr`. use std::ops::Deref; @@ -22,7 +26,8 @@ where fn method(&self); } -// Test 2 +// This works for `Trait: Super<...Ty::Assoc...>` before the `where`. +// We need to assume `A: Associator`. trait Associator { type Point; @@ -34,4 +39,60 @@ trait Trait + ?Sized>: Marker { fn method(&self); } +// Regression test for : we need to be careful with +// projection clauses involving `RustaceansAreAwesome`. Here, if we simply assumed that +// `::RowIndex == ::RowIndex`, we'd end up with +// ambiguity, as we also assume `::RowIndex == ::RowIndex`.`Self` +// stands in for the `Self` type of the impl we're imagining dispatching to (pretending +// `RustaceansAreAwesome` is a trait object). + +pub trait Matrix { + type Coordinates; +} + +pub trait Matrix2D: Matrix::RowIndex> { + type RowIndex; +} + +pub trait Transposable>: Matrix2D { + fn transpose(&self) -> T; +} + +// An example where we can't add any additional projections without introducing ambiguity: we don't +// want to assume `<() as HasAssoc>::Assoc` is both `Self` and `RustaceansAreAwesome`. At the time +// of writing, we let `<() as HasAssoc>::Assoc` normalize to `Self` during receiver dispatchability +// checking. This should be fine, since to call methods on a `dyn TechnicallyDynCompatible`, we'd +// need `<() as HasAssoc>::Assoc` to be `dyn TechnicallyDynCompatible`. This is the same reasoning +// that lets us assume `RustaceansAreAwesome` implements its trait at all: to use the trait object, +// it must implement the trait; otherwise, receiver dispatchability doesn't mean much. + +trait HasAssoc { + type Assoc; +} + +impl HasAssoc for () { + type Assoc = (); +} + +trait Parent {} + +trait TechnicallyDynCompatible +where + (): HasAssoc, + Self: Parent<<() as HasAssoc>::Assoc>, +{ + fn f(&self) {} +} + +// Since we have `TechnincallyDynCompatible` defined, let's keep its dyn-compatibility from breaking +// accidentally (and also sanity-check the above comment). + +impl Parent<()> for () {} +impl TechnicallyDynCompatible for () {} + +fn technically_dyn_compatible_is_dyn_compatible() { + let x: &dyn TechnicallyDynCompatible = &(); + // We can't call `x.f()` since `<() as HasAssoc>::Assoc` isn't `dyn TechnicallyDynCompatible`. +} + fn main() {} From 3e2bec149a3c2e66ed7251fcb01c961058f3c221 Mon Sep 17 00:00:00 2001 From: cezarbbb Date: Tue, 29 Sep 2026 08:54:55 +0800 Subject: [PATCH 08/13] Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports --- compiler/rustc_codegen_ssa/src/back/link.rs | 52 +----- .../rustc_codegen_ssa/src/back/symbol_edit.rs | 67 +++---- .../src/back/symbol_export.rs | 63 +++++++ .../decorated_lib.rs | 38 ++++ .../rmake.rs | 174 +++++++++++------- 5 files changed, 236 insertions(+), 158 deletions(-) create mode 100644 tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 221998abf6128..3b15188fc6c2e 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -44,7 +44,7 @@ use rustc_span::{Symbol, bug}; use rustc_structures::{CrateType, NativeLibKind}; use rustc_target::spec::crt_objects::CrtObjects; use rustc_target::spec::{ - Arch, BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents, + BinaryFormat, Cc, CfgAbi, Env, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFeatures, LinkerFlavor, LinkerFlavorCli, Lld, Os, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, }; @@ -58,7 +58,7 @@ use super::linker::{self, Linker}; use super::metadata::{MetadataPosition, create_wrapper_file}; use super::rmeta_link::RmetaLinkCache; use super::rpath::{self, RPathConfig}; -use super::{apple, rmeta_link, versioned_llvm_target}; +use super::{apple, rmeta_link, symbol_export, versioned_llvm_target}; use crate::base::needs_allocator_shim_for_linking; use crate::{ CodegenLintLevelSpecs, CompiledModule, CompiledModules, CrateInfo, NativeLib, SymbolExport, @@ -2755,10 +2755,6 @@ fn add_rpath_args( } } -fn strip_numeric_suffix<'a>(base: &'a str, suffix: impl AsRef, fallback: &'a str) -> &'a str { - if suffix.as_ref().parse::().is_ok() { base } else { fallback } -} - fn undecorate_c_symbol<'a>( name: &'a str, sess: &Session, @@ -2771,47 +2767,11 @@ fn undecorate_c_symbol<'a>( name.strip_prefix('_') } BinaryFormat::Coff => { - // MSVC C++ mangled names start with '?' and use a completely different - // decorating scheme that includes '@@' as structural delimiters. - // They must not be subjected to C calling-convention undecoration. - if name.starts_with('?') { - return Some(name); + // COFF undecoration is shared with `symbol_edit`'s binary-level matching. + match symbol_export::coff_machine_for_arch(&sess.target.arch) { + Some(machine) => Some(symbol_export::undecorate_coff_symbol(name, machine, kind)), + None => Some(name), } - Some(match sess.target.arch { - Arch::X86 => { - // COFF 32-bit: strip calling-convention decorations. - if let Some(rest) = name.strip_prefix('@') { - // fastcall: @foo@N -> foo - rest.rsplit_once('@') - .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) - .unwrap_or(name) - } else if let Some(stripped) = name.strip_prefix('_') { - if let Some((base, suffix)) = stripped.rsplit_once('@') { - // stdcall: _foo@N -> foo - strip_numeric_suffix(base, suffix, stripped) - } else { - // cdecl: _foo -> foo - stripped - } - } else { - // vectorcall: foo@@N -> foo - name.rsplit_once("@@") - .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) - .unwrap_or(name) - } - } - Arch::X86_64 => { - // COFF 64-bit: vectorcall mangling (foo@@N -> foo) also applies on x86_64. - name.rsplit_once("@@") - .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) - .unwrap_or(name) - } - Arch::Arm64EC if kind == SymbolExportKind::Text => { - // Arm64EC: `#` prefix distinguishes ARM64EC text symbols from x64 thunks. - name.strip_prefix('#').unwrap_or(name) - } - _ => name, - }) } // ELF: no decoration _ => Some(name), diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs index fa6fc1368e133..2ed758112a9fb 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs @@ -12,6 +12,9 @@ use object::read::elf::{SectionHeader as _, Sym as _}; use object::read::macho::Nlist; use object::{Endianness, elf, macho, pe}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_middle::middle::exported_symbols::SymbolExportKind; + +use super::symbol_export::undecorate_coff_symbol; struct Patch { offset: usize, @@ -58,20 +61,8 @@ pub(super) fn apply_edits<'a>( rename, mem::offset_of!(macho::Nlist32, n_type), ), - Some(object::File::Coff(f)) => coff_edit_impl( - data, - f.coff_header(), - hide, - rename, - coff_strip_underscore(f.coff_header()), - ), - Some(object::File::CoffBig(f)) => coff_edit_impl( - data, - f.coff_header(), - hide, - rename, - coff_strip_underscore(f.coff_header()), - ), + Some(object::File::Coff(f)) => coff_edit_impl(data, f.coff_header(), hide, rename), + Some(object::File::CoffBig(f)) => coff_edit_impl(data, f.coff_header(), hide, rename), _ => None, }; match result { @@ -99,28 +90,20 @@ pub(super) fn collect_internal_names( object::File::MachO32(_) => { macho_collect_impl::>(data, exported, out) } - object::File::Coff(f) => coff_collect_impl( - data, - f.coff_header(), - exported, - out, - coff_strip_underscore(f.coff_header()), - ), - object::File::CoffBig(f) => coff_collect_impl( - data, - f.coff_header(), - exported, - out, - coff_strip_underscore(f.coff_header()), - ), + object::File::Coff(f) => coff_collect_impl(data, f.coff_header(), exported, out), + object::File::CoffBig(f) => coff_collect_impl(data, f.coff_header(), exported, out), _ => {} } } -/// Whether this machine's COFF ABI decorates external symbols with a leading `_` -/// (i686 only). -fn coff_strip_underscore(header: &impl CoffHeader) -> bool { - header.machine() == pe::IMAGE_FILE_MACHINE_I386 +/// The `SymbolExportKind` of a COFF symbol, so `#`-prefixed `Arm64EC` text symbols are told +/// apart from data symbols during undecoration. +fn coff_symbol_kind(sym: &impl object::read::coff::ImageSymbol) -> SymbolExportKind { + if sym.derived_type() == pe::IMAGE_SYM_DTYPE_FUNCTION { + SymbolExportKind::Text + } else { + SymbolExportKind::Data + } } fn elf_collect_impl>( @@ -485,10 +468,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>( header: &'data Coff, exported: &FxHashSet, out: &mut FxHashSet, - strip_underscore: bool, ) { let Ok(symbols) = header.symbols(data) else { return }; let strings = symbols.strings(); + let machine = header.machine(); for (_index, sym) in symbols.iter() { let sclass = sym.storage_class(); @@ -499,15 +482,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>( continue; } let Ok(name_bytes) = sym.name(strings) else { continue }; - let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; - if strip_underscore { - name = name.strip_prefix('_').unwrap_or(&name).to_string(); - } - let is_exported = exported.contains(&name) - || (header.machine() == pe::IMAGE_FILE_MACHINE_ARM64EC - && name.strip_prefix('#').is_some_and(|name| exported.contains(name))); - if !is_exported { - out.insert(name); + let Ok(name) = str::from_utf8(name_bytes) else { continue }; + let name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); + if !exported.contains(name) { + out.insert(name.to_string()); } } } @@ -517,7 +495,6 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( header: &'data Coff, hide: bool, rename: Option<&(FxHashSet, &str)>, - strip_underscore: bool, ) -> Option> { // COFF has no visibility concept, so hiding is unsupported; the caller // has already warned and does not request it. @@ -545,6 +522,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( let Ok(symbols) = header.symbols(data) else { return None }; let strings = symbols.strings(); + let machine = header.machine(); let mut renames = Vec::new(); for (index, sym) in symbols.iter() { @@ -554,8 +532,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( } let Ok(name_bytes) = sym.name(strings) else { continue }; let Ok(name) = str::from_utf8(name_bytes) else { continue }; - let check_name = - if strip_underscore { name.strip_prefix('_').unwrap_or(name) } else { name }; + let check_name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); if rename.is_some_and(|(rename_set, _)| rename_set.contains(check_name)) { renames.push(RenameEntry { name_field_offset: symbol_bytes_offset + index.0 * sym_size, diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index b11dee2ca3827..bda08821c9f22 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -1,5 +1,6 @@ use std::collections::hash_map::Entry::*; +use object::pe; use rustc_abi::{CanonAbi, X86Call}; use rustc_ast::expand::allocator::{AllocatorKind, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name}; use rustc_crate_store::CrateDepKind; @@ -813,6 +814,68 @@ pub(crate) fn exporting_symbol_name_for_instance_in_crate<'tcx>( maybe_emutls_symbol_name(tcx, symbol, &undecorated).unwrap_or(undecorated) } +fn strip_numeric_suffix<'a>(base: &'a str, suffix: impl AsRef, fallback: &'a str) -> &'a str { + if suffix.as_ref().parse::().is_ok() { base } else { fallback } +} + +/// COFF `IMAGE_FILE_MACHINE_*` for an arch with decorated symbols, or `None`. +pub(super) fn coff_machine_for_arch(arch: &Arch) -> Option { + match *arch { + Arch::X86 => Some(pe::IMAGE_FILE_MACHINE_I386), + Arch::X86_64 => Some(pe::IMAGE_FILE_MACHINE_AMD64), + Arch::Arm64EC => Some(pe::IMAGE_FILE_MACHINE_ARM64EC), + _ => None, + } +} + +/// Undecorated counterpart of [`linking_symbol_name_for_instance_in_crate`]. +pub(super) fn undecorate_coff_symbol<'a>( + name: &'a str, + machine: u16, + kind: SymbolExportKind, +) -> &'a str { + // MSVC C++ mangled names start with '?' and use a completely different + // decorating scheme that includes '@@' as structural delimiters. + // They must not be subjected to C calling-convention undecoration. + if name.starts_with('?') { + return name; + } + match machine { + pe::IMAGE_FILE_MACHINE_I386 => { + if let Some(rest) = name.strip_prefix('@') { + // fastcall: @foo@N -> foo + rest.rsplit_once('@') + .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) + .unwrap_or(name) + } else if let Some(stripped) = name.strip_prefix('_') { + if let Some((base, suffix)) = stripped.rsplit_once('@') { + // stdcall: _foo@N -> foo + strip_numeric_suffix(base, suffix, stripped) + } else { + // cdecl: _foo -> foo + stripped + } + } else { + // vectorcall: foo@@N -> foo + name.rsplit_once("@@") + .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) + .unwrap_or(name) + } + } + pe::IMAGE_FILE_MACHINE_AMD64 => { + // vectorcall: foo@@N -> foo + name.rsplit_once("@@") + .map(|(base, suffix)| strip_numeric_suffix(base, suffix, name)) + .unwrap_or(name) + } + pe::IMAGE_FILE_MACHINE_ARM64EC if kind == SymbolExportKind::Text => { + // `#` prefix distinguishes ARM64EC text symbols from x64 thunks. + name.strip_prefix('#').unwrap_or(name) + } + _ => name, + } +} + /// On amdhsa, `gpu-kernel` functions have an associated metadata object with a `.kd` suffix. /// Add it to the symbols list for all kernel functions, so that it is exported in the linked /// object. diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs new file mode 100644 index 0000000000000..698a9a8168f85 --- /dev/null +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/decorated_lib.rs @@ -0,0 +1,38 @@ +#![crate_type = "staticlib"] +#![feature(abi_vectorcall)] + +#[no_mangle] +pub extern "C" fn decorated_cdecl(a: i32, b: i32) -> i32 { + a + b +} + +// stdcall/fastcall are decorated only on x86; elsewhere they are deprecated aliases for "C". +#[cfg(target_arch = "x86")] +#[no_mangle] +pub extern "stdcall" fn decorated_stdcall(a: i32, b: i32) -> i32 { + a + b +} + +#[cfg(target_arch = "x86")] +#[no_mangle] +pub extern "fastcall" fn decorated_fastcall(a: i32, b: i32) -> i32 { + a + b +} + +// vectorcall is x86/x86_64-only and MSVC-only (GCC does not support it). A single `u64` +// argument is 8 bytes on both x86 (4-byte pointer width, rounded up) and x86_64, so its `@@N` +// decoration suffix is a stable `@@8` regardless of target. +#[cfg(all(target_env = "msvc", any(target_arch = "x86", target_arch = "x86_64")))] +#[no_mangle] +pub extern "vectorcall" fn decorated_vectorcall(x: u64) -> u64 { + x +} + +fn internal_decorated_helper() -> i32 { + 1 +} + +#[no_mangle] +pub extern "C" fn decorated_calls_internal() -> i32 { + internal_decorated_helper() + 1 +} diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs index 0b3f445a6ec70..12ddd353bc24d 100644 --- a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs @@ -1,3 +1,8 @@ +//! Tests that `-Zstaticlib-rename-internal-symbols` renames internal symbols on COFF targets +//! while leaving exported symbols untouched, taking COFF decoration (i686 cdecl `_` / +//! stdcall `_@N` / fastcall `@N` / vectorcall `@@N`, Arm64EC text `#`) into account so decorated +//! exported symbols are neither renamed nor missed. + //@ only-windows //@ ignore-cross-compile @@ -7,9 +12,12 @@ use run_make_support::object::read::archive::ArchiveFile; use run_make_support::object::read::coff::ImageSymbol as _; use run_make_support::object::{File, pe}; use run_make_support::path_helpers::source_root; -use run_make_support::{cc, extra_c_flags, rfs, run, rustc, static_lib_name}; +use run_make_support::{ + cc, extra_c_flags, is_windows_msvc, rfs, run, rustc, static_lib_name, target, +}; -const EXPORTED: &[&str] = &["my_add", "my_hash_lookup", "call_internal", "my_safe_div"]; +/// The undecorated exported names of the base fixture (`lib.rs`). +const BASE_EXPORTED: &[&str] = &["my_add", "my_hash_lookup", "call_internal", "my_safe_div"]; fn main() { let hide_sibling = source_root().join("tests/run-make/staticlib-hide-internal-symbols"); @@ -24,65 +32,49 @@ fn main() { test_rs_suffix_present(); test_dual_staticlib_linking(); test_hide_and_rename(); + test_decorated_symbols(); } -fn test_basic_functionality() { - let lib_name = static_lib_name("lib"); - +/// Compile `.rs` into a staticlib under `-Zstaticlib-rename-internal-symbols`. +fn compile_staticlib(crate_name: &str) -> String { + let lib_name = static_lib_name(crate_name); rustc() - .input("lib.rs") + .input(format!("{crate_name}.rs")) .crate_type("staticlib") .arg("-Zstaticlib-rename-internal-symbols") .opt() .run(); + lib_name +} - cc().input("main.c").input(&lib_name).out_exe("main").args(extra_c_flags()).run(); - run("main"); +/// Link `main_c` against `libs` into `exe`, then run it. +fn link_and_run(main_c: &str, libs: &[&str], exe: &str) { + let mut cmd = cc(); + cmd.input(main_c); + for lib in libs { + cmd.input(*lib); + } + cmd.out_exe(exe).args(extra_c_flags()).run(); + run(exe); +} - rfs::remove_file(&lib_name); +fn test_basic_functionality() { + let lib = compile_staticlib("lib"); + link_and_run("main.c", &[lib.as_str()], "main"); + rfs::remove_file(&lib); } fn test_rs_suffix_present() { - let lib_name = static_lib_name("lib"); - - rustc() - .input("lib.rs") - .crate_type("staticlib") - .arg("-Zstaticlib-rename-internal-symbols") - .opt() - .run(); - - let data = rfs::read(&lib_name); - check_rename_symbols(&data); - - rfs::remove_file(&lib_name); + let lib = compile_staticlib("lib"); + let data = rfs::read(&lib); + check_rename_symbols(&data, BASE_EXPORTED, MatchMode::Undecorated); + rfs::remove_file(&lib); } fn test_dual_staticlib_linking() { - let liba_name = static_lib_name("liba"); - let libb_name = static_lib_name("libb"); - - rustc() - .input("liba.rs") - .crate_type("staticlib") - .arg("-Zstaticlib-rename-internal-symbols") - .opt() - .run(); - - rustc() - .input("libb.rs") - .crate_type("staticlib") - .arg("-Zstaticlib-rename-internal-symbols") - .opt() - .run(); - - cc().input("dual_main.c") - .input(&liba_name) - .input(&libb_name) - .out_exe("dual_main") - .args(extra_c_flags()) - .run(); - run("dual_main"); + let liba = compile_staticlib("liba"); + let libb = compile_staticlib("libb"); + link_and_run("dual_main.c", &[liba.as_str(), libb.as_str()], "dual_main"); } /// On COFF, hiding is unsupported and must only produce a warning, while @@ -103,15 +95,50 @@ fn test_hide_and_rename() { .assert_exit_code(0); let data = rfs::read(&lib_name); - check_rename_symbols(&data); - - cc().input("main.c").input(&lib_name).out_exe("main").args(extra_c_flags()).run(); - run("main"); + check_rename_symbols(&data, BASE_EXPORTED, MatchMode::Undecorated); + link_and_run("main.c", &[lib_name.as_str()], "main"); rfs::remove_file(&lib_name); } -fn check_rename_symbols(archive_data: &[u8]) { +/// Assert the stdcall/fastcall/vectorcall exports (`_@N` / `@N` / `@@N`) don't get renamed +/// into their undecorated form. +fn test_decorated_symbols() { + let lib = compile_staticlib("decorated_lib"); + let data = rfs::read(&lib); + check_rename_symbols(&data, &decorated_exports(), MatchMode::Raw); + rfs::remove_file(&lib); +} + +/// Raw decorated names `decorated_lib.rs` emits: i686 cdecl `_`, stdcall `_@N`, fastcall `@N`, +/// and vectorcall `@@N` (MSVC x86/x86_64 only). +fn decorated_exports() -> Vec<&'static str> { + let mut exports = if target().starts_with("i686") { + vec![ + "_decorated_cdecl", + "_decorated_calls_internal", + "_decorated_stdcall@8", + "@decorated_fastcall@8", + ] + } else { + vec!["decorated_cdecl", "decorated_calls_internal"] + }; + if is_windows_msvc() && (target().starts_with("i686") || target().starts_with("x86_64")) { + exports.push("decorated_vectorcall@@8"); + } + exports +} + +/// How exported symbol names are matched against the object file's symbol table. +#[derive(Clone, Copy)] +enum MatchMode { + /// Strip the target's leading prefix (`_` i686 cdecl, `#` Arm64EC text) before matching. + Undecorated, + /// Match raw object-file names verbatim. + Raw, +} + +fn check_rename_symbols(archive_data: &[u8], exported: &[&str], mode: MatchMode) { let archive = ArchiveFile::parse(archive_data).unwrap(); let mut found_exported = HashSet::new(); let mut found_rs_suffix = false; @@ -125,19 +152,29 @@ fn check_rename_symbols(archive_data: &[u8]) { // parse directly from the borrowed slice. let data = member.data(archive_data).unwrap(); match File::parse(data) { - Ok(File::Coff(f)) => { - check_coff_symbols(f.coff_header(), data, &mut found_exported, &mut found_rs_suffix) - } - Ok(File::CoffBig(f)) => { - check_coff_symbols(f.coff_header(), data, &mut found_exported, &mut found_rs_suffix) - } + Ok(File::Coff(f)) => check_coff_symbols( + f.coff_header(), + data, + exported, + mode, + &mut found_exported, + &mut found_rs_suffix, + ), + Ok(File::CoffBig(f)) => check_coff_symbols( + f.coff_header(), + data, + exported, + mode, + &mut found_exported, + &mut found_rs_suffix, + ), Ok(_) => panic!("unexpected object file format in archive member"), Err(e) => panic!("failed to parse archive member: {e}"), } } assert!(found_rs_suffix, "expected to find at least one renamed symbol with .rs suffix"); - for expected in EXPORTED { + for expected in exported { assert!( found_exported.contains(*expected), "expected to find exported symbol `{expected}` in archive" @@ -148,6 +185,8 @@ fn check_rename_symbols(archive_data: &[u8]) { fn check_coff_symbols( header: &Coff, data: &[u8], + exported: &[&str], + mode: MatchMode, found_exported: &mut HashSet, found_rs_suffix: &mut bool, ) { @@ -178,18 +217,19 @@ fn check_coff_symbols( let Ok(name_bytes) = symbol.name(strings) else { continue }; let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; - // Adjust for various symbol decorations. - match header.machine() { - pe::IMAGE_FILE_MACHINE_I386 => { - name = name.strip_prefix('_').unwrap_or(&name).to_string(); - } - pe::IMAGE_FILE_MACHINE_ARM64EC => { - name = name.strip_prefix('#').unwrap_or(&name).to_string(); + if matches!(mode, MatchMode::Undecorated) { + match header.machine() { + pe::IMAGE_FILE_MACHINE_I386 => { + name = name.strip_prefix('_').unwrap_or(&name).to_string(); + } + pe::IMAGE_FILE_MACHINE_ARM64EC => { + name = name.strip_prefix('#').unwrap_or(&name).to_string(); + } + _ => {} } - _ => {} } - if EXPORTED.contains(&name.as_str()) { + if exported.contains(&name.as_str()) { assert!( !name.contains(".rs"), "exported symbol `{name}` should not contain .rs suffix" From 19735e029ebca1b9591db21c7695780762a33157 Mon Sep 17 00:00:00 2001 From: Ada Alakbarova Date: Sat, 1 Aug 2026 12:31:13 +0200 Subject: [PATCH 09/13] add MISSING_GENERIC_TYPE_VISITABLE lint --- compiler/rustc_lint/src/diagnostics.rs | 11 ++ compiler/rustc_lint/src/internal.rs | 73 +++++++++- compiler/rustc_lint/src/lib.rs | 6 + compiler/rustc_span/src/symbol.rs | 2 + compiler/rustc_type_ir/src/generic_visit.rs | 1 + compiler/rustc_type_ir/src/lib.rs | 6 + compiler/rustc_type_ir/src/visit.rs | 1 + .../missing-generic-type-visitable-derive.rs | 130 ++++++++++++++++++ ...ssing-generic-type-visitable-derive.stderr | 65 +++++++++ 9 files changed, 290 insertions(+), 5 deletions(-) create mode 100644 tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs create mode 100644 tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index d9fc1703f8c03..601f1213650e1 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -3261,3 +3261,14 @@ pub(crate) enum RawBorrowViaReferenceSuggestion<'a> { #[help("consider using `&raw {$mutbl}` for a safer and more explicit raw pointer")] Spanless { mutbl: &'a str }, } + +#[derive(Diagnostic)] +#[diag("missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable`")] +#[note_once( + "`GenericTypeVisitable` is rust-analyzer's version of `TypeVisitable`; it should be implemented whenever the latter is" +)] +#[help("mark the type with `#[derive(GenericTypeVisitable)]`")] +#[help( + "or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable`" +)] +pub(crate) struct MissingGenericTypeVisitableDeriveDiag; diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index b32fa2515238a..bce726311e51f 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -8,17 +8,20 @@ use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, HirId}; +use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint_defs::{declare_lint_pass, declare_tool_lint}; use rustc_middle::ty::{self, ClausePolarity, GenericArgsRef}; use rustc_span::hygiene::{ExpnKind, MacroKind}; -use rustc_span::{Span, sym}; +use rustc_span::{DUMMY_SP, Span, sym}; +use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; +use rustc_trait_selection::traits::{Obligation, ObligationCause}; use crate::diagnostics::{ AttributeKindInFindAttr, BadOptAccessDiag, DefaultHashTypesDiag, - ImplicitSysrootCrateImportDiag, LintPassByHand, NonGlobImportTypeIrInherent, QueryInstability, - QueryUntracked, RustcMustMatchExhaustivelyNotExhaustive, SpanUseEqCtxtDiag, - SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrDirectUse, - TypeIrInherentUsage, TypeIrTraitUsage, + ImplicitSysrootCrateImportDiag, LintPassByHand, MissingGenericTypeVisitableDeriveDiag, + NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, + RustcMustMatchExhaustivelyNotExhaustive, SpanUseEqCtxtDiag, SymbolInternStringLiteralDiag, + TyQualified, TykindDiag, TykindKind, TypeIrDirectUse, TypeIrInherentUsage, TypeIrTraitUsage, }; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; @@ -873,3 +876,63 @@ impl<'tcx> LateLintPass<'tcx> for RustcMustMatchExhaustively { } } } + +declare_tool_lint! { + /// The `missing_generic_type_visitable_derive` lint detects types implementing `TypeVisitable` + /// but not deriving `GenericTypeVisitable`. + /// + /// `GenericTypeVisitable` is the analog of `TypeVisitable` used by rust-analyzer, and needs to + /// be implemented whenever `TypeVisitable` is. See [`rustc_type_ir::generic_visit`] for more + /// information. + pub rustc::MISSING_GENERIC_TYPE_VISITABLE_DERIVE, + // This lint is meant to be manually enabled in selected crates (currently only `rustc_type_ir`) + Allow, + "Forbid implementing `TypeVisitable` without deriving `GenericTypeVisitable`", + report_in_external_macro: true +} + +declare_lint_pass!(MissingGenericTypeVisitableDerive => [MISSING_GENERIC_TYPE_VISITABLE_DERIVE]); + +impl<'tcx> LateLintPass<'tcx> for MissingGenericTypeVisitableDerive { + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { + // lint ADTs except unions, as neither trait can be implemented on the latter + if matches!(item.kind, hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..)) + && let Some(regular_id) = cx.tcx.get_diagnostic_item(sym::TypeVisitable) + && let Some(generic_id) = cx.tcx.get_diagnostic_item(sym::GenericTypeVisitable) + && let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(cx.typing_env()) + && let self_ty = { + let self_id = item.owner_id.to_def_id(); + let args = infcx.fresh_args_for_item(DUMMY_SP, self_id); + cx.tcx.type_of(self_id).instantiate(cx.tcx, args).skip_norm_wip() + } + // check whether `Self: TypeVisitable` holds for some `I`.. + && { + let predicate = + ty::TraitRef::new(cx.tcx, regular_id, [self_ty, infcx.next_ty_var(DUMMY_SP)]); + let obligation = + Obligation::new(cx.tcx, ObligationCause::dummy(), param_env, predicate); + + // NOTE: I initially went with `predicate_must_hold_modulo_regions` (which is what's + // used by Clippy's [`implements_trait`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.implements_trait.html), + // but that returned `false` more often than I'd hoped, and so I went with the + // next-most strict function. + infcx.predicate_may_hold(&obligation) + } + // ..while `Self: GenericTypeVisitable` doesn't + && { + let predicate = + ty::TraitRef::new(cx.tcx, generic_id, [self_ty, infcx.next_ty_var(DUMMY_SP)]); + let obligation = + Obligation::new(cx.tcx, ObligationCause::dummy(), param_env, predicate); + + !infcx.predicate_may_hold(&obligation) + } + { + cx.emit_span_lint( + MISSING_GENERIC_TYPE_VISITABLE_DERIVE, + item.span, + MissingGenericTypeVisitableDeriveDiag, + ); + } + } +} diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index deea9e1bbc13c..bf716b099f856 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -298,6 +298,7 @@ late_lint_methods!( BadOptAccess: BadOptAccess, DefaultHashTypes: DefaultHashTypes, DisallowedPassByRef: DisallowedPassByRef, + MissingGenericTypeVisitableDerive: MissingGenericTypeVisitableDerive, QueryStability: QueryStability, RustcMustMatchExhaustively: RustcMustMatchExhaustively, SpanUseEqCtxt: SpanUseEqCtxt, @@ -769,6 +770,11 @@ fn register_internals(store: &mut LintStore) { // // Late pass: RustcMustMatchExhaustively LintId::of(RUSTC_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 + // each relevant crate. + // LintId::of(MISSING_GENERIC_TYPE_VISITABLE_DERIVE), ], ); } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3debf3248ff80..eb8fd764d5e67 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -237,6 +237,7 @@ symbols! { From, FromIterator, FromResidual, + GenericTypeVisitable, GlobalAlloc, Hash, HashMap, @@ -358,6 +359,7 @@ symbols! { TyCtxt, TyKind, Type, + TypeVisitable, Union, Unresolved, Unsafe, diff --git a/compiler/rustc_type_ir/src/generic_visit.rs b/compiler/rustc_type_ir/src/generic_visit.rs index e2663a61421f1..5fc5ab39f6eb1 100644 --- a/compiler/rustc_type_ir/src/generic_visit.rs +++ b/compiler/rustc_type_ir/src/generic_visit.rs @@ -26,6 +26,7 @@ use crate::Interner; /// /// Therefore, it is advised to instead derive this using the derive /// macro located in `rustc_macros`. +#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "GenericTypeVisitable")] pub unsafe trait GenericTypeVisitable { fn generic_visit_with(&self, visitor: &mut V); } diff --git a/compiler/rustc_type_ir/src/lib.rs b/compiler/rustc_type_ir/src/lib.rs index 38b717b2cadb4..0be6a2c4152dc 100644 --- a/compiler/rustc_type_ir/src/lib.rs +++ b/compiler/rustc_type_ir/src/lib.rs @@ -27,6 +27,12 @@ #![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))] +// NOTE: the outer `cfg_attr` is only there so that r-a doesn't see the nightly-only `bootstrap` +// in the inner `cfg_attr`. When the latter is removed, the former can be removed as well. +#![cfg_attr( + feature = "nightly", + cfg_attr(not(bootstrap), deny(rustc::missing_generic_type_visitable_derive)) +)] // tidy-alphabetical-end extern crate self as rustc_type_ir; diff --git a/compiler/rustc_type_ir/src/visit.rs b/compiler/rustc_type_ir/src/visit.rs index 008b6aeb239ee..396c8c17a2952 100644 --- a/compiler/rustc_type_ir/src/visit.rs +++ b/compiler/rustc_type_ir/src/visit.rs @@ -59,6 +59,7 @@ use crate::{self as ty, Const, Interner, PredicateProxy, Region, TypeFlags}; /// /// To implement this conveniently, use the derive macro located in /// `rustc_macros`. +#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "TypeVisitable")] pub trait TypeVisitable: fmt::Debug { /// The entry point for visiting. To visit a value `t` with a visitor `v` /// call: `t.visit_with(v)`. diff --git a/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs new file mode 100644 index 0000000000000..d92cb12cf9a54 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs @@ -0,0 +1,130 @@ +//@ compile-flags: -Z unstable-options +// FIXME(bootstrap): Remove the ignore once we promote the next beta. +//@ ignore-stage1 + +#![crate_type = "lib"] +#![feature(rustc_private)] +#![deny(rustc::missing_generic_type_visitable_derive)] + +extern crate rustc_type_ir; +extern crate rustc_type_ir_macros; + +use rustc_type_ir::{GenericTypeVisitable, TypeVisitable}; +use rustc_type_ir::{Interner, TypeVisitor, VisitorResult}; +use rustc_type_ir_macros::{GenericTypeVisitable, TypeVisitable_Generic}; +use std::{fmt::Debug, hash::Hash}; + +// Should lint: `TypeVisitable` is implemented, but `GenericTypeVisitable` isn't + +#[derive(Debug, TypeVisitable_Generic)] +struct DerivesRegular; +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +#[derive(Debug)] +struct ImplsRegular; +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +impl TypeVisitable for ImplsRegular { + fn visit_with>(&self, _f: &mut F) -> F::Result { + F::Result::output() + } +} + +// Same but with an enum + +#[derive(Debug, TypeVisitable_Generic)] +enum EnumDerivesRegular {} +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +// Same but the type is generic, over the interner + +#[derive(TypeVisitable_Generic)] +struct GenericOverIDerivesRegular(I::Clause); +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +// manually hand-rolled `#[derive_where(Debug; I: Interner)]` +impl std::fmt::Debug for GenericOverIDerivesRegular { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + todo!() + } +} + +// Same but the type is generic, over an unrelated type + +#[derive(TypeVisitable_Generic)] +struct GenericOverTDerivesRegular([T; 67]); +//~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + +// manually hand-rolled `#[derive(Debug)]`, to avoid the spurious bound on `T` +impl Debug for GenericOverTDerivesRegular { + fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + todo!() + } +} + +// Should not lint: both traits are implemented + +#[derive(Debug, TypeVisitable_Generic, GenericTypeVisitable)] +struct DerivesBoth; + +#[derive(Debug, GenericTypeVisitable)] +struct ImplsAndDerives; + +impl TypeVisitable for ImplsAndDerives { + fn visit_with>(&self, _f: &mut F) -> F::Result { + F::Result::output() + } +} + +#[derive(Debug, TypeVisitable_Generic)] +struct DerivesAndImpls; + +unsafe impl GenericTypeVisitable for DerivesAndImpls { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + +#[derive(Debug)] +struct ImplsBoth; + +impl TypeVisitable for ImplsBoth { + fn visit_with>(&self, _f: &mut F) -> F::Result { + F::Result::output() + } +} + +unsafe impl GenericTypeVisitable for ImplsBoth { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + +// Should not lint: `TypeVisitable` isn't implemented, so `GenericTypeVisitable` doesn't need to be +// either + +struct ImplsNone; + +// Should not lint: `GenericTypeVisitable` is implemented but `TypeVisitable` isn't -- weird, but +// okay for the purposes of this lint + +#[derive(GenericTypeVisitable)] +struct DerivesGeneric; + +struct ImplsGeneric; + +unsafe impl GenericTypeVisitable for ImplsGeneric { + fn generic_visit_with(&self, _visitor: &mut V) {} +} + +// FIXME(ada4a): this will currently lint, and suggest adding a derive, even though ther's already +// one present. The actual problem is that the item has a _field_ that doesn't implement the trait, +// which makes the impl generated by the derive on this item unusable due to unsatisfied bounds. +// +// There are two ways of solving this: +// - in the lint, emit a different suggestion -- namely, to add a derive to the problematic field's +// type -- if we see that the linted type already has a derive. +// - change the derive to add _assertions_ that the bound holds for each field type, and not just +// trait bounds on the impl. +#[derive(Debug)] +#[derive(TypeVisitable_Generic, GenericTypeVisitable)] +struct FieldDoesntImplGeneric { + //~^ ERROR missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + field: ImplsRegular, +} diff --git a/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr new file mode 100644 index 0000000000000..94e1297adab27 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.stderr @@ -0,0 +1,65 @@ +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:20:1 + | +LL | struct DerivesRegular; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `GenericTypeVisitable` is rust-analyzer's version of `TypeVisitable`; it should be implemented whenever the latter is + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` +note: the lint level is defined here + --> $DIR/missing-generic-type-visitable-derive.rs:7:9 + | +LL | #![deny(rustc::missing_generic_type_visitable_derive)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:24:1 + | +LL | struct ImplsRegular; + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:36:1 + | +LL | enum EnumDerivesRegular {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:42:1 + | +LL | struct GenericOverIDerivesRegular(I::Clause); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:55:1 + | +LL | struct GenericOverTDerivesRegular([T; 67]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: missing `#[derive(GenericTypeVisitable)]` on a type which implements `TypeVisitable` + --> $DIR/missing-generic-type-visitable-derive.rs:127:1 + | +LL | / struct FieldDoesntImplGeneric { +LL | | +LL | | field: ImplsRegular, +LL | | } + | |_^ + | + = help: mark the type with `#[derive(GenericTypeVisitable)]` + = help: or, if `GenericTypeVisitable` is derived, check whether all fields implement `GenericTypeVisitable` + +error: aborting due to 6 previous errors + From 7cbe17e9d29105aa35390399a3be019890f3422e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 8 Oct 2026 10:18:58 +0200 Subject: [PATCH 10/13] Condense AdtDef lang item checks into one match --- compiler/rustc_middle/src/ty/adt.rs | 35 +++++++++-------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 8ad5de3fa85cc..5b57f802c0c4f 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -384,30 +384,17 @@ impl AdtDefData { if find_attr!(tcx, did, Fundamental) { flags |= AdtFlags::IS_FUNDAMENTAL; } - if tcx.is_lang_item(did, LangItem::PhantomData) { - flags |= AdtFlags::IS_PHANTOM_DATA; - } - if tcx.is_lang_item(did, LangItem::OwnedBox) { - flags |= AdtFlags::IS_BOX; - } - if tcx.is_lang_item(did, LangItem::ManuallyDrop) { - flags |= AdtFlags::IS_MANUALLY_DROP; - } - if tcx.is_lang_item(did, LangItem::MaybeDangling) { - flags |= AdtFlags::IS_MAYBE_DANGLING; - } - if tcx.is_lang_item(did, LangItem::UnsafeCell) { - flags |= AdtFlags::IS_UNSAFE_CELL; - } - if tcx.is_lang_item(did, LangItem::UnsafePinned) { - flags |= AdtFlags::IS_UNSAFE_PINNED; - } - if tcx.is_lang_item(did, LangItem::Pin) { - flags |= AdtFlags::IS_PIN; - } - if tcx.is_lang_item(did, LangItem::FieldRepresentingType) { - flags |= AdtFlags::IS_FIELD_REPRESENTING_TYPE; - } + flags |= match tcx.as_lang_item(did) { + Some(LangItem::PhantomData) => AdtFlags::IS_PHANTOM_DATA, + Some(LangItem::OwnedBox) => AdtFlags::IS_BOX, + Some(LangItem::ManuallyDrop) => AdtFlags::IS_MANUALLY_DROP, + Some(LangItem::MaybeDangling) => AdtFlags::IS_MAYBE_DANGLING, + Some(LangItem::UnsafeCell) => AdtFlags::IS_UNSAFE_CELL, + Some(LangItem::UnsafePinned) => AdtFlags::IS_UNSAFE_PINNED, + Some(LangItem::Pin) => AdtFlags::IS_PIN, + Some(LangItem::FieldRepresentingType) => AdtFlags::IS_FIELD_REPRESENTING_TYPE, + _ => AdtFlags::NO_ADT_FLAGS, + }; AdtDefData { did, variants, flags, repr } } From 02f6b388b19b3ab332035d505c63ba6a605fe99c Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sun, 26 Jul 2026 17:12:50 +0200 Subject: [PATCH 11/13] _Complex for mips --- compiler/rustc_target/src/callconv/mips.rs | 41 ++++++++++++++++++---- tests/codegen-llvm/complex-abi.rs | 31 ++++++++++------ 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_target/src/callconv/mips.rs b/compiler/rustc_target/src/callconv/mips.rs index d3a39d05b4964..3cce9095bd847 100644 --- a/compiler/rustc_target/src/callconv/mips.rs +++ b/compiler/rustc_target/src/callconv/mips.rs @@ -1,16 +1,43 @@ -use rustc_abi::{HasDataLayout, Size, TyAbiInterface}; +use rustc_abi::{Float, HasDataLayout, Integer, Numeric, Reg, RegKind, Size, TyAbiInterface}; +use rustc_span::bug; -use crate::callconv::{ArgAbi, FnAbi, Reg, Uniform}; +use crate::callconv::{ArgAbi, CastTarget, FnAbi, Uniform}; -fn classify_ret(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size) +fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, offset: &mut Size) where + Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, { - if !ret.layout.is_aggregate() { - ret.extend_integer_width_to(32); - } else { + let dl = cx.data_layout(); + let size = ret.layout.size; + + // Complex types with unsupported component types are returned as an aggregate. + let is_supported_complex_component = |numeric| match numeric { + Numeric::Int(Integer::I8 | Integer::I16 | Integer::I32 | Integer::I64, _) => true, + Numeric::Int(Integer::I128, _) => false, + Numeric::Float(Float::F32 | Float::F64) => true, + Numeric::Float(Float::F16 | Float::F128) => false, + Numeric::Float(Float::F16B | Float::PpcF128) => bug!("unsupported on mips"), + }; + + if let Some(component) = ret.layout.complex_number(cx) + && is_supported_complex_component(component) + { + match component { + Numeric::Int(Integer::I8 | Integer::I16, _) => { + // Pack Complex<{integer}> into a single register if that fits. + ret.cast_to(Reg { kind: RegKind::Integer, size }); + } + _ => { + let reg = Reg { kind: component.reg_kind(), size: component.size() }; + ret.cast_to(CastTarget::from(Uniform::new(reg, size))); + } + } + } else if ret.layout.is_aggregate() { ret.make_indirect(); - *offset += cx.data_layout().pointer_size(); + *offset += dl.pointer_size(); + } else { + ret.extend_integer_width_to(32); } } diff --git a/tests/codegen-llvm/complex-abi.rs b/tests/codegen-llvm/complex-abi.rs index 45224bd9316fe..cd0afa1b4dab8 100644 --- a/tests/codegen-llvm/complex-abi.rs +++ b/tests/codegen-llvm/complex-abi.rs @@ -83,16 +83,18 @@ //@ [MIPS64EL] compile-flags: --target mips64el-unknown-linux-gnuabi64 //@ [MIPS64EL] needs-llvm-components: mips +//@ revisions: MIPS MIPSEL +//@ [MIPS] compile-flags: --target mips-unknown-linux-gnu +//@ [MIPS] needs-llvm-components: mips +//@ [MIPSEL] compile-flags: --target mipsel-unknown-linux-gnu +//@ [MIPSEL] needs-llvm-components: mips + // FIXME: the below revisions are deliberately disabled for now. // revisions: POWERPC // [POWERPC] compile-flags: --target powerpc-unknown-linux-gnu // [POWERPC] needs-llvm-components: powerpc -// revisions: MIPS -// [MIPS] compile-flags: --target mips-unknown-linux-gnu -// [MIPS] needs-llvm-components: mips - // revisions: NVPTX // [NVPTX] compile-flags: --target nvptx64-nvidia-cuda // [NVPTX] needs-llvm-components: nvptx @@ -151,7 +153,8 @@ pub extern "C" fn cplx_f32(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} { float, float } @cplx_f32({ float, float } {{.*}}) // MIPS64: define{{.*}} { float, float } @cplx_f32([2 x float] {{.*}}) // MIPS64EL: define{{.*}} { float, float } @cplx_f32([2 x float] {{.*}}) - // MIPS: define{{.*}} { float, float } @cplx_f32([2 x i32] {{.*}}) + // MIPS: define{{.*}} [2 x float] @cplx_f32([2 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x float] @cplx_f32([2 x i32] {{.*}}) // NVPTX: define{{.*}} { float, float } @cplx_f32(ptr {{.*}} byval({ float, float }) {{.*}}) // POWERPC64: define{{.*}} { float, float } @cplx_f32({ float, float } %0) // POWERPC64LE: define{{.*}} { float, float } @cplx_f32({ float, float } %0) @@ -186,7 +189,8 @@ pub extern "C" fn cplx_f64(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} { double, double } @cplx_f64({ double, double } {{.*}}) // MIPS64: define{{.*}} { double, double } @cplx_f64([2 x double] {{.*}}) // MIPS64EL: define{{.*}} { double, double } @cplx_f64([2 x double] {{.*}}) - // MIPS: define{{.*}} { double, double } @cplx_f64(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x double] @cplx_f64([4 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x double] @cplx_f64([4 x i32] {{.*}}) // NVPTX: define{{.*}} { double, double } @cplx_f64(ptr {{.*}} byval({ double, double }) {{.*}}) // POWERPC64: define{{.*}} { double, double } @cplx_f64({ double, double } %0) // POWERPC64LE: define{{.*}} { double, double } @cplx_f64({ double, double } %0) @@ -238,7 +242,8 @@ pub extern "C" fn cplx_i8(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} i64 @cplx_i8(i64{{.*}}) // MIPS64: define{{.*}} i16 @cplx_i8(i16 inreg {{.*}}) // MIPS64EL: define{{.*}} i16 @cplx_i8(i16 inreg {{.*}}) - // MIPS: define{{.*}} { i8, i8 } @cplx_i8(i16 {{.*}}) + // MIPS: define{{.*}} i16 @cplx_i8(i32 {{.*}}) + // MIPSEL: define{{.*}} i16 @cplx_i8(i32 {{.*}}) // NVPTX: define{{.*}} { i8, i8 } @cplx_i8(ptr {{.*}} byval({ i8, i8 }) {{.*}}) // POWERPC64: define{{.*}} { i8, i8 } @cplx_i8({ i8, i8 } %0) // POWERPC64LE: define{{.*}} { i8, i8 } @cplx_i8({ i8, i8 } %0) @@ -273,7 +278,8 @@ pub extern "C" fn cplx_i16(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} i64 @cplx_i16(i64{{.*}}) // MIPS64: define{{.*}} i32 @cplx_i16(i32 inreg {{.*}}) // MIPS64EL: define{{.*}} i32 @cplx_i16(i32 inreg {{.*}}) - // MIPS: define{{.*}} { i16, i16 } @cplx_i16(i32 {{.*}}) + // MIPS: define{{.*}} i32 @cplx_i16(i32 {{.*}}) + // MIPSEL: define{{.*}} i32 @cplx_i16(i32 {{.*}}) // NVPTX: define{{.*}} { i16, i16 } @cplx_i16(ptr {{.*}} byval({ i16, i16 }) {{.*}}) // POWERPC64: define{{.*}} { i16, i16 } @cplx_i16(i16 {{.*}}, i16 {{.*}}) // POWERPC64LE: define{{.*}} { i16, i16 } @cplx_i16(i16 {{.*}}, i16 {{.*}}) @@ -308,7 +314,8 @@ pub extern "C" fn cplx_i32(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} i64 @cplx_i32(i64 {{.*}}) // MIPS64: define{{.*}} i64 @cplx_i32(i64 inreg {{.*}}) // MIPS64EL: define{{.*}} i64 @cplx_i32(i64 inreg {{.*}}) - // MIPS: define{{.*}} { i32, i32 } @cplx_i32(i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x i32] @cplx_i32([2 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x i32] @cplx_i32([2 x i32] {{.*}}) // NVPTX: define{{.*}} { i32, i32 } @cplx_i32(ptr {{.*}} byval({ i32, i32 }) {{.*}}) // POWERPC64: define{{.*}} { i32, i32 } @cplx_i32({ i32, i32 } %0) // POWERPC64LE: define{{.*}} { i32, i32 } @cplx_i32({ i32, i32 } %0) @@ -343,7 +350,8 @@ pub extern "C" fn cplx_i64(x: Complex) -> Complex { // LOONGARCH64: define{{.*}} [2 x i64] @cplx_i64([2 x i64] {{.*}}) // MIPS64: define{{.*}} { i64, i64 } @cplx_i64(i128 {{.*}}) // MIPS64EL: define{{.*}} { i64, i64 } @cplx_i64(i128 {{.*}}) - // MIPS: define{{.*}} { i64, i64 } @cplx_i64(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x i64] @cplx_i64([4 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x i64] @cplx_i64([4 x i32] {{.*}}) // NVPTX: define{{.*}} { i64, i64 } @cplx_i64(ptr {{.*}} byval({ i64, i64 }) {{.*}}) // POWERPC64: define{{.*}} { i64, i64 } @cplx_i64({ i64, i64 } %0) // POWERPC64LE: define{{.*}} { i64, i64 } @cplx_i64({ i64, i64 } %0) @@ -383,7 +391,8 @@ pub extern "C" fn wrapper_cplx_i64( // LOONGARCH64: define{{.*}} [2 x i64] @wrapper_cplx_i64([2 x i64] {{.*}}) // MIPS64: define{{.*}} { i64, i64 } @wrapper_cplx_i64(i128 {{.*}}) // MIPS64EL: define{{.*}} { i64, i64 } @wrapper_cplx_i64(i128 {{.*}}) - // MIPS: define{{.*}} { i64, i64 } @wrapper_cplx_i64(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}) + // MIPS: define{{.*}} [2 x i64] @wrapper_cplx_i64([4 x i32] {{.*}}) + // MIPSEL: define{{.*}} [2 x i64] @wrapper_cplx_i64([4 x i32] {{.*}}) // NVPTX: define{{.*}} { i64, i64 } @wrapper_cplx_i64(ptr {{.*}} byval({ i64, i64 }) {{.*}}) // POWERPC64: define{{.*}} { i64, i64 } @wrapper_cplx_i64({ i64, i64 } %0) // POWERPC64LE: define{{.*}} { i64, i64 } @wrapper_cplx_i64({ i64, i64 } %0) From e5ddf33d4cb6c7f7f9b3752e08e01c2a2ae5a5fc Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Thu, 8 Oct 2026 10:44:16 +0100 Subject: [PATCH 12/13] Add `bf16` to arm features --- compiler/rustc_target/src/target_features.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 6a06a45f8ad19..6564c3543b6d2 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -171,6 +171,7 @@ static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ }, &[], ), + ("bf16", Unstable(sym::arm_target_feature), &["neon"]), ("crc", Unstable(sym::arm_target_feature), &[]), ("d32", Unstable(sym::arm_target_feature), &[]), ("dotprod", Unstable(sym::arm_target_feature), &["neon"]), From 8186e2c2c59d026d7d98514cf18b82ddb3e05174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 8 Oct 2026 10:13:45 +0000 Subject: [PATCH 13/13] Include enclosing item's context on const errors --- .../src/const_eval/eval_queries.rs | 3 + compiler/rustc_const_eval/src/diagnostics.rs | 4 ++ .../rustc_const_eval/src/interpret/stack.rs | 3 + compiler/rustc_const_eval/src/util/mod.rs | 48 +++++++++++++++- .../miri/tests/fail/const-ub-checks.stderr | 2 + .../miri/tests/fail/erroneous_const.stderr | 1 + tests/ui/any/hrtb.next.stderr | 2 + tests/ui/any/hrtb.old.stderr | 2 + tests/ui/any/hrtb2.next.stderr | 2 + tests/ui/any/hrtb2.old.stderr | 2 + .../any/try_as_dyn_generic_trait.next.stderr | 2 + .../any/try_as_dyn_generic_trait.old.stderr | 2 + .../assoc-const-panic-in-match-91514.stderr | 1 + .../defaults-not-assumed-fail.stderr | 2 + .../ice-normalize-inherent-assoc-const.stderr | 1 + .../generic_const_exprs/simple_fail.stderr | 2 + .../const-generics/issues/issue-100313.stderr | 5 ++ .../invalid-patterns.32bit.stderr | 4 ++ .../invalid-patterns.64bit.stderr | 4 ++ tests/ui/const-ptr/forbidden_slices.stderr | 4 ++ tests/ui/const-ptr/out_of_bounds_read.stderr | 6 ++ tests/ui/consts/assert-type-intrinsics.stderr | 9 +++ .../ui/consts/assoc_const_generic_impl.stderr | 1 + .../consts/const-assert-unchecked-ub.stderr | 2 + tests/ui/consts/const-compare-bytes-ub.stderr | 23 ++++++++ tests/ui/consts/const-deref-ptr.stderr | 1 + .../const-err-enum-discriminant.32bit.stderr | 1 + .../const-err-enum-discriminant.64bit.stderr | 1 + tests/ui/consts/const-err-late.stderr | 2 + .../ui/consts/const-eval-fail-too-big.stderr | 2 + ...ssign-to-static-within-other-static.stderr | 1 + .../consts/const-eval/c-variadic-fail.stderr | 52 +++++++++++++++++ .../const-eval/const-eval-overflow-3.stderr | 2 + .../const-eval/const-eval-overflow-4.stderr | 1 + .../const-eval/const-eval-overflow2.stderr | 14 +++++ .../const-eval/const-eval-overflow2b.stderr | 14 +++++ .../const-eval/const-eval-overflow2c.stderr | 14 +++++ ...inter-values-in-various-types.64bit.stderr | 57 +++++++++++++++++++ .../const-eval/do_not_const_check.stderr | 2 + .../heap/dealloc_intrinsic_dangling.stderr | 2 + .../heap/dealloc_intrinsic_duplicate.stderr | 2 + .../dealloc_intrinsic_incorrect_layout.stderr | 8 +++ .../heap/make-global-dangling.stderr | 2 + .../const-eval/heap/make-global-other.stderr | 1 + .../const-eval/heap/make-global-twice.stderr | 2 + .../heap/ptr_made_global_mutated.stderr | 2 + .../index-out-of-bounds-never-type.stderr | 1 + tests/ui/consts/const-eval/issue-43197.stderr | 3 + tests/ui/consts/const-eval/issue-44578.stderr | 1 + .../const-eval/issue-50814-2.mir-opt.stderr | 1 + .../const-eval/issue-50814-2.normal.stderr | 1 + tests/ui/consts/const-eval/issue-50814.stderr | 2 + tests/ui/consts/const-eval/issue-85155.stderr | 2 + ...sue-91827-extern-types-field-offset.stderr | 2 + .../mod-static-with-const-fn.stderr | 1 + .../const-eval/panic-assoc-never-type.stderr | 1 + .../const-eval/ptr_fragments_mixed.stderr | 4 ++ .../consts/const-eval/raw-pointer-ub.stderr | 10 ++++ .../consts/const-eval/read_partial_ptr.stderr | 8 +++ .../consts/const-eval/shift_overflow.stderr | 2 + .../const-eval/ub-enum-overwrite.stderr | 2 + tests/ui/consts/const-eval/ub-enum.stderr | 2 + .../const-eval/ub-invalid-values.stderr | 2 + tests/ui/consts/const-eval/ub-nonnull.stderr | 2 + tests/ui/consts/const-eval/ub-ref-ptr.stderr | 2 + .../const-eval/ub-slice-get-unchecked.stderr | 2 + .../ui/consts/const-eval/ub-uninhabit.stderr | 2 + .../ub-write-through-immutable.stderr | 4 ++ .../const-eval/union-const-eval-field.stderr | 1 + tests/ui/consts/const-eval/union-ice.stderr | 4 ++ .../const-len-underflow-subspans.stderr | 1 + tests/ui/consts/const-ptr-is-null.stderr | 2 + .../consts/const_refs_to_static_fail.stderr | 2 + .../ui/consts/const_transmute_type_id.stderr | 2 + .../ui/consts/const_transmute_type_id2.stderr | 2 + .../ui/consts/const_transmute_type_id3.stderr | 2 + .../ui/consts/const_transmute_type_id4.stderr | 2 + .../ui/consts/const_transmute_type_id5.stderr | 2 + .../ui/consts/const_transmute_type_id6.stderr | 2 + tests/ui/consts/copy-intrinsic.stderr | 8 +++ tests/ui/consts/eval-enum.stderr | 3 + .../detect-extra-ub.with_flag.stderr | 13 +++++ tests/ui/consts/issue-64506.stderr | 2 + tests/ui/consts/issue-miri-1910.stderr | 2 + tests/ui/consts/large_const_alloc.stderr | 3 + .../consts/miri_unleashed/assoc_const.stderr | 1 + .../miri_unleashed/assoc_const_2.stderr | 1 + tests/ui/consts/miri_unleashed/box.stderr | 1 + .../const_refers_to_static.stderr | 4 ++ .../const_refers_to_static_cross_crate.stderr | 2 + tests/ui/consts/miri_unleashed/drop.stderr | 2 + .../miri_unleashed/extern-static.stderr | 2 + .../consts/miri_unleashed/inline_asm.stderr | 1 + .../miri_unleashed/mutating_global.stderr | 2 + .../ui/consts/miri_unleashed/ptr_arith.stderr | 3 + tests/ui/consts/miri_unleashed/tls.stderr | 2 + .../consts/missing_span_in_backtrace.stderr | 14 +++-- .../mono-reachable-invalid-const.stderr | 3 + tests/ui/consts/offset_from_ub.stderr | 27 +++++++++ .../qualif-indirect-mutation-fail.stderr | 4 ++ tests/ui/consts/recursive-static-write.stderr | 4 ++ .../collect-in-called-fn.noopt.stderr | 1 + .../collect-in-called-fn.opt.stderr | 1 + .../collect-in-dead-closure.noopt.stderr | 1 + .../collect-in-dead-closure.opt.stderr | 1 + .../collect-in-dead-drop.noopt.stderr | 1 + .../collect-in-dead-drop.opt.stderr | 1 + ...-in-dead-fn-behind-assoc-type.noopt.stderr | 1 + ...ct-in-dead-fn-behind-assoc-type.opt.stderr | 1 + ...ect-in-dead-fn-behind-generic.noopt.stderr | 1 + ...llect-in-dead-fn-behind-generic.opt.stderr | 1 + ...in-dead-fn-behind-opaque-type.noopt.stderr | 1 + ...t-in-dead-fn-behind-opaque-type.opt.stderr | 1 + .../collect-in-dead-fn.noopt.stderr | 1 + .../collect-in-dead-fn.opt.stderr | 1 + ...ollect-in-dead-fnptr-in-const.noopt.stderr | 1 + .../collect-in-dead-fnptr-in-const.opt.stderr | 1 + .../collect-in-dead-fnptr.noopt.stderr | 1 + .../collect-in-dead-fnptr.opt.stderr | 1 + .../collect-in-dead-move.noopt.stderr | 1 + .../collect-in-dead-move.opt.stderr | 1 + .../collect-in-dead-vtable.noopt.stderr | 1 + .../collect-in-dead-vtable.opt.stderr | 1 + .../collect-in-promoted-const.noopt.stderr | 1 + .../collect-in-promoted-const.opt.stderr | 1 + .../interpret-in-const-called-fn.noopt.stderr | 1 + .../interpret-in-const-called-fn.opt.stderr | 1 + .../interpret-in-promoted.noopt.stderr | 2 + .../interpret-in-promoted.opt.stderr | 2 + .../interpret-in-static.noopt.stderr | 1 + .../interpret-in-static.opt.stderr | 1 + .../slice-index-overflow-issue-130284.stderr | 2 + .../static_mut_containing_mut_ref2.stderr | 1 + .../uninhabited-const-issue-61744.stderr | 1 + ...uginfo-type-name-layout-ice-94961-1.stderr | 1 + ...uginfo-type-name-layout-ice-94961-2.stderr | 1 + tests/ui/enum-discriminant/eval-error.stderr | 2 + tests/ui/error-codes/E0080.stderr | 3 + .../ctfe-id-unlimited.return_.stderr | 6 ++ .../unsatisfied-evaluatable-bounds.stderr | 2 + ...st_monomorphization_error_backtrace.stderr | 2 + .../const-expr-generic-err.stderr | 2 + tests/ui/inline-const/required-const.stderr | 2 + .../intrinsic-raw_eq-const-bad.stderr | 4 ++ ...nvalid-unsized-in-always-sized-tail.stderr | 1 + tests/ui/layout/too-big-no-dce.stderr | 1 + ...le-due-to-trivial-bounds-ice-135138.stderr | 2 + .../unknown-when-no-type-parameter.stderr | 2 + .../unknown-when-ptr-metadata-is-DST.stderr | 2 + tests/ui/limits/issue-17913.32bit.stderr | 1 + tests/ui/limits/issue-17913.64bit.stderr | 1 + tests/ui/limits/issue-55878.stderr | 1 + tests/ui/limits/issue-75158-64.stderr | 1 + .../vtable-try-as-dyn.full-debuginfo.stderr | 1 + .../vtable-try-as-dyn.no-debuginfo.stderr | 1 + .../reflection/trait_info_of_too_big.stderr | 2 + .../variant_index_out_of_bounds.stderr | 2 + .../ui/simd/const-err-trumps-simd-err.stderr | 1 + ...rivial-const-with-impossible-bounds.stderr | 1 + tests/ui/transmutability/uninhabited.stderr | 12 ++++ 160 files changed, 588 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 5764400148ca7..c8cbd955acc5e 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -519,6 +519,9 @@ fn report_eval_error<'tcx>( where_ = if num_frames == 0 { "here" } else { "inside this call" }, ), ); + for span in crate::util::context_spans(*ecx.tcx, span, cid.instance.def_id()) { + diag.span_context(span); + } for frame in frames { diag.subdiagnostic(frame); } diff --git a/compiler/rustc_const_eval/src/diagnostics.rs b/compiler/rustc_const_eval/src/diagnostics.rs index 995356fd3b488..f7c5d6c36cecb 100644 --- a/compiler/rustc_const_eval/src/diagnostics.rs +++ b/compiler/rustc_const_eval/src/diagnostics.rs @@ -310,6 +310,7 @@ pub(crate) struct NonConstImplNote { #[derive(Clone)] pub(crate) struct FrameNote { pub span: Span, + pub span_context: Vec, pub times: i32, pub where_: &'static str, pub instance: String, @@ -322,6 +323,9 @@ impl Subdiagnostic for FrameNote { if self.has_label && !self.span.is_dummy() { span.push_span_label(self.span, msg!("the failure occurred here")); } + for sp in &self.span_context { + span.push_span_context(*sp); + } let msg = msg!( r#"{$times -> [0] inside {$where_ -> diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 8a731e25d8f4b..61cc31479b652 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -230,18 +230,21 @@ impl<'tcx> FrameInfo<'tcx> { diagnostics::FrameNote { where_: "closure", span, + span_context: vec![], instance: String::new(), times: 0, has_label: false, } } else { let instance = format!("{}", self.instance); + let span_context = crate::util::context_spans(tcx, span, self.instance.def_id()); // Note: this triggers a `must_produce_diag` state, which means that if we ever get // here we must emit a diagnostic. We should never display a `FrameInfo` unless we // actually want to emit a warning or error to the user. diagnostics::FrameNote { where_: "instance", span, + span_context, instance, times: 0, has_label: false, diff --git a/compiler/rustc_const_eval/src/util/mod.rs b/compiler/rustc_const_eval/src/util/mod.rs index c63d7748087c9..e7fcdef588d2e 100644 --- a/compiler/rustc_const_eval/src/util/mod.rs +++ b/compiler/rustc_const_eval/src/util/mod.rs @@ -1,4 +1,8 @@ +use rustc_hir::def::DefKind; +use rustc_hir::def_id::DefId; use rustc_middle::mir; +use rustc_middle::ty::TyCtxt; +use rustc_span::Span; mod alignment; pub(crate) mod caller_location; @@ -16,7 +20,7 @@ pub use self::type_name::type_name; /// same type as the result. #[inline] pub fn binop_left_homogeneous(op: mir::BinOp) -> bool { - use rustc_middle::mir::BinOp::*; + use mir::BinOp::*; match op { Add | AddUnchecked | Sub | SubUnchecked | Mul | MulUnchecked | Div | Rem | BitXor | BitAnd | BitOr | Offset | Shl | ShlUnchecked | Shr | ShrUnchecked => true, @@ -30,7 +34,7 @@ pub fn binop_left_homogeneous(op: mir::BinOp) -> bool { /// same type as the LHS. #[inline] pub fn binop_right_homogeneous(op: mir::BinOp) -> bool { - use rustc_middle::mir::BinOp::*; + use mir::BinOp::*; match op { Add | AddUnchecked | AddWithOverflow | Sub | SubUnchecked | SubWithOverflow | Mul | MulUnchecked | MulWithOverflow | Div | Rem | BitXor | BitAnd | BitOr | Eq | Ne | Lt @@ -48,3 +52,43 @@ pub fn unop_homogeneous(op: mir::UnOp) -> bool { mir::UnOp::PtrMetadata => false, } } + +pub fn context_spans(tcx: TyCtxt<'_>, span: Span, def_id: DefId) -> Vec { + // For consts where the enclosing item might be useful context, include their spans in the + // diagnostic. + let instance_span = tcx.def_span(def_id).shrink_to_lo(); + let parent = tcx.parent(def_id); + let parent_span = tcx.def_span(parent).shrink_to_lo(); + let mut span = span; + if let Some(sp) = span.macro_backtrace().last() { + // We want the outermost span when macros are involved, as we don't care about the + // macro's internal consts for the purposes of adding context. + span = sp.call_site; + } + match (tcx.def_kind(def_id), tcx.def_kind(parent)) { + ( + _, + DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Trait + | DefKind::Impl { .. } + | DefKind::TyAlias + | DefKind::Const + | DefKind::Fn + | DefKind::Static { .. }, + ) + | (DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy, _) + if span.eq_ctxt(instance_span) && span.eq_ctxt(parent_span) => + { + vec![instance_span, parent_span] + } + (_, DefKind::Variant) if span.eq_ctxt(instance_span) && span.eq_ctxt(parent_span) => { + vec![instance_span, parent_span, tcx.def_span(tcx.parent(parent)).shrink_to_lo()] + } + (DefKind::Const | DefKind::Static { .. }, _) if span.eq_ctxt(instance_span) => { + vec![instance_span] + } + _ => vec![], + } +} diff --git a/src/tools/miri/tests/fail/const-ub-checks.stderr b/src/tools/miri/tests/fail/const-ub-checks.stderr index df2d5653d2db6..cd01bbbbf72d2 100644 --- a/src/tools/miri/tests/fail/const-ub-checks.stderr +++ b/src/tools/miri/tests/fail/const-ub-checks.stderr @@ -1,6 +1,8 @@ error[E0080]: accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required --> tests/fail/const-ub-checks.rs:LL:CC | +LL | const UNALIGNED_READ: () = unsafe { +... LL | ptr.read(); | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here diff --git a/src/tools/miri/tests/fail/erroneous_const.stderr b/src/tools/miri/tests/fail/erroneous_const.stderr index 1aa87dd7188ce..6a897832fefc7 100644 --- a/src/tools/miri/tests/fail/erroneous_const.stderr +++ b/src/tools/miri/tests/fail/erroneous_const.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> tests/fail/erroneous_const.rs:LL:CC | +LL | impl PrintName { LL | const VOID: ! = panic!(); | ^^^^^^^^ evaluation of `PrintName::::VOID` failed here diff --git a/tests/ui/any/hrtb.next.stderr b/tests/ui/any/hrtb.next.stderr index 385b3c3cf2212..69d8f93f6a166 100644 --- a/tests/ui/any/hrtb.next.stderr +++ b/tests/ui/any/hrtb.next.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn for<'a> Foo<'a, 'a>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/hrtb.old.stderr b/tests/ui/any/hrtb.old.stderr index 385b3c3cf2212..69d8f93f6a166 100644 --- a/tests/ui/any/hrtb.old.stderr +++ b/tests/ui/any/hrtb.old.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn for<'a> Foo<'a, 'a>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/hrtb2.next.stderr b/tests/ui/any/hrtb2.next.stderr index dfe000dc503a8..842f42e5680e0 100644 --- a/tests/ui/any/hrtb2.next.stderr +++ b/tests/ui/any/hrtb2.next.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb2.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn Foo<'_>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/hrtb2.old.stderr b/tests/ui/any/hrtb2.old.stderr index dfe000dc503a8..842f42e5680e0 100644 --- a/tests/ui/any/hrtb2.old.stderr +++ b/tests/ui/any/hrtb2.old.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/hrtb2.rs:15:25 | +LL | const _: () = { +LL | let x: Option<*const dyn Foo<'_>> = None; LL | let _dy: &dyn Bar = try_as_dyn(&x).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/try_as_dyn_generic_trait.next.stderr b/tests/ui/any/try_as_dyn_generic_trait.next.stderr index 99382f9a4032c..61ea708d650db 100644 --- a/tests/ui/any/try_as_dyn_generic_trait.next.stderr +++ b/tests/ui/any/try_as_dyn_generic_trait.next.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/try_as_dyn_generic_trait.rs:22:51 | +LL | const _: () = { +LL | let payload: Payload = std::ptr::null(); LL | let convert: &dyn Convert<&'static Payload> = try_as_dyn(&payload).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/any/try_as_dyn_generic_trait.old.stderr b/tests/ui/any/try_as_dyn_generic_trait.old.stderr index 99382f9a4032c..61ea708d650db 100644 --- a/tests/ui/any/try_as_dyn_generic_trait.old.stderr +++ b/tests/ui/any/try_as_dyn_generic_trait.old.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: called `Option::unwrap()` on a `None` value --> $DIR/try_as_dyn_generic_trait.rs:22:51 | +LL | const _: () = { +LL | let payload: Payload = std::ptr::null(); LL | let convert: &dyn Convert<&'static Payload> = try_as_dyn(&payload).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr b/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr index 38b0901aa14c9..4fb847bebefdf 100644 --- a/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr +++ b/tests/ui/associated-consts/assoc-const-panic-in-match-91514.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/assoc-const-panic-in-match-91514.rs:15:23 | +LL | impl S { LL | const CONST: u8 = panic!(); | ^^^^^^^^ evaluation of `S::CONST` failed here diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 8b38905e1c576..0aa8ba32863e3 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/defaults-not-assumed-fail.rs:9:19 | +LL | trait Tr { +... LL | const B: u8 = Self::A + 1; | ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed here diff --git a/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr b/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr index 5ce8a67bc7810..27cd39f4fb1cb 100644 --- a/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr +++ b/tests/ui/associated-inherent-types/ice-normalize-inherent-assoc-const.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: not yet implemented --> $DIR/ice-normalize-inherent-assoc-const.rs:10:28 | +LL | impl Foo { LL | const ASSOC_C: usize = todo!(); | ^^^^^^^ evaluation of `Foo::ASSOC_C` failed here diff --git a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr index 94a91159e956f..5287137d0ec3b 100644 --- a/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr +++ b/tests/ui/const-generics/generic_const_exprs/simple_fail.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/simple_fail.rs:9:10 | +LL | fn test() -> Arr +LL | where LL | [u8; N - 1]: Sized, | ^^^^^ evaluation of `test::<0>::{constant#0}` failed here diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 17bad92d8dfa5..723b87491e4cc 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,12 +1,17 @@ error[E0080]: writing to ALLOC$ID which is read-only --> $DIR/issue-100313.rs:18:5 | +LL | const _: () = { +LL | let x = T::<{ &true }>; LL | x.set_false(); | ^^^^^^^^^^^^^ evaluation of `_` failed inside this call | note: inside `T::<&true>::set_false` --> $DIR/issue-100313.rs:11:13 | +LL | impl T { +LL | const fn set_false(&self) { +LL | unsafe { LL | *(B as *const bool as *mut bool) = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr index 31a2accccd7fd..a6fb8aaa87a12 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr @@ -49,6 +49,8 @@ LL | fn get_flag() -> Option { error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | +LL | fn main() { +... LL | get_flag::(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here | @@ -81,6 +83,8 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:44:58 | +LL | fn main() { +... LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here | diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr index 31a2accccd7fd..a6fb8aaa87a12 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr @@ -49,6 +49,8 @@ LL | fn get_flag() -> Option { error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:40:32 | +LL | fn main() { +... LL | get_flag::(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here | @@ -81,6 +83,8 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory --> $DIR/invalid-patterns.rs:44:58 | +LL | fn main() { +... LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here | diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index e23b4e5b1aa75..8983a54cb08e4 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -108,6 +108,8 @@ LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:54:25 | +LL | pub static R2: &[u32] = unsafe { +LL | let ptr = &D0 as *const u32; LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore | ^^^^^^^^^^ evaluation of `R2` failed here @@ -160,6 +162,8 @@ LL | pub static R7: &[u16] = unsafe { error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID+0x1 which is only 7 bytes from the end of the allocation --> $DIR/forbidden_slices.rs:79:25 | +LL | pub static R8: &[u64] = unsafe { +LL | let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::(); LL | from_ptr_range(ptr..ptr.add(1)) | ^^^^^^^^^^ evaluation of `R8` failed here diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 8465d69db28e7..83bb4fe3226fa 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,18 +1,24 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:8:33 | +LL | fn main() { +... LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:10:39 | +LL | fn main() { +... LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/out_of_bounds_read.rs:12:37 | +LL | fn main() { +... LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_MUT_READ` failed here diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 775b95ac30a40..70e6318b988de 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -1,18 +1,27 @@ error[E0080]: evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` --> $DIR/assert-type-intrinsics.rs:10:9 | +LL | fn main() { +... +LL | const _BAD1: () = unsafe { LL | MaybeUninit::::uninit().assume_init(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD1` failed here error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid --> $DIR/assert-type-intrinsics.rs:14:9 | +LL | fn main() { +... +LL | const _BAD2: () = { LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD2` failed here error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid --> $DIR/assert-type-intrinsics.rs:18:9 | +LL | fn main() { +... +LL | const _BAD3: () = { LL | intrinsics::assert_zero_valid::<&'static i32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD3` failed here diff --git a/tests/ui/consts/assoc_const_generic_impl.stderr b/tests/ui/consts/assoc_const_generic_impl.stderr index fc8986a34c566..b7913fe4b5ca5 100644 --- a/tests/ui/consts/assoc_const_generic_impl.stderr +++ b/tests/ui/consts/assoc_const_generic_impl.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 4 --> $DIR/assoc_const_generic_impl.rs:9:33 | +LL | impl ZeroSized for T { LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `::I_AM_ZERO_SIZED` failed here diff --git a/tests/ui/consts/const-assert-unchecked-ub.stderr b/tests/ui/consts/const-assert-unchecked-ub.stderr index d8e68fc9bee23..cd9918640c235 100644 --- a/tests/ui/consts/const-assert-unchecked-ub.stderr +++ b/tests/ui/consts/const-assert-unchecked-ub.stderr @@ -1,6 +1,8 @@ error[E0080]: `assume` called with `false` --> $DIR/const-assert-unchecked-ub.rs:3:5 | +LL | const _: () = unsafe { +LL | let n = u32::MAX.count_ones(); LL | std::hint::assert_unchecked(n < 32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr index 94098c1e26407..a3c4a824a6802 100644 --- a/tests/ui/consts/const-compare-bytes-ub.stderr +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -1,36 +1,53 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got null pointer --> $DIR/const-compare-bytes-ub.rs:9:9 | +LL | fn main() { +LL | const LHS_NULL: i32 = unsafe { LL | compare_bytes(0 as *const u8, 2 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_NULL` failed here error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-compare-bytes-ub.rs:13:9 | +LL | fn main() { +... +LL | const RHS_NULL: i32 = unsafe { LL | compare_bytes(1 as *const u8, 0 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_NULL` failed here error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-compare-bytes-ub.rs:17:9 | +LL | fn main() { +... +LL | const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe { LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:21:9 | +LL | fn main() { +... +LL | const LHS_OUT_OF_BOUNDS: i32 = unsafe { LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID which is only 3 bytes from the end of the allocation --> $DIR/const-compare-bytes-ub.rs:25:9 | +LL | fn main() { +... +LL | const RHS_OUT_OF_BOUNDS: i32 = unsafe { LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:29:9 | +LL | fn main() { +... +LL | const LHS_UNINIT: i32 = unsafe { LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_UNINIT` failed here | @@ -41,6 +58,9 @@ LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) error[E0080]: reading memory at ALLOC$ID[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory --> $DIR/const-compare-bytes-ub.rs:33:9 | +LL | fn main() { +... +LL | const RHS_UNINIT: i32 = unsafe { LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_UNINIT` failed here | @@ -51,6 +71,9 @@ LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) error[E0080]: unable to turn pointer into integer --> $DIR/const-compare-bytes-ub.rs:37:9 | +LL | fn main() { +... +LL | const WITH_PROVENANCE: i32 = unsafe { LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::WITH_PROVENANCE` failed here | diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr index aa89aedac318e..3d55b1e555241 100644 --- a/tests/ui/consts/const-deref-ptr.stderr +++ b/tests/ui/consts/const-deref-ptr.stderr @@ -1,6 +1,7 @@ error[E0080]: memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const-deref-ptr.rs:4:30 | +LL | fn main() { LL | static C: u64 = unsafe { *(0xdeadbeef as *const u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::C` failed here diff --git a/tests/ui/consts/const-err-enum-discriminant.32bit.stderr b/tests/ui/consts/const-err-enum-discriminant.32bit.stderr index 864364139594a..4cb4ae6293b8b 100644 --- a/tests/ui/consts/const-err-enum-discriminant.32bit.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.32bit.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:10:21 | +LL | enum Bar { LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], | ^^^^^^^^^^^^^^^ evaluation of `Bar::Boo::{constant#0}` failed here | diff --git a/tests/ui/consts/const-err-enum-discriminant.64bit.stderr b/tests/ui/consts/const-err-enum-discriminant.64bit.stderr index 9212299bffbd4..89c75600a6c08 100644 --- a/tests/ui/consts/const-err-enum-discriminant.64bit.stderr +++ b/tests/ui/consts/const-err-enum-discriminant.64bit.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x0..0x8], and this operation requires initialized memory --> $DIR/const-err-enum-discriminant.rs:10:21 | +LL | enum Bar { LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], | ^^^^^^^^^^^^^^^ evaluation of `Bar::Boo::{constant#0}` failed here | diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 02be7bbe10c47..b2f693fa3d2c5 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-late.rs:14:21 | +LL | impl S { LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ evaluation of `S::::FOO` failed here @@ -13,6 +14,7 @@ LL | black_box((S::::FOO, S::::FOO)); error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/const-err-late.rs:14:21 | +LL | impl S { LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ evaluation of `S::::FOO` failed here diff --git a/tests/ui/consts/const-eval-fail-too-big.stderr b/tests/ui/consts/const-eval-fail-too-big.stderr index d58efbf6d8c65..28c41bedc0c54 100644 --- a/tests/ui/consts/const-eval-fail-too-big.stderr +++ b/tests/ui/consts/const-eval-fail-too-big.stderr @@ -1,6 +1,8 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/const-eval-fail-too-big.rs:4:28 | +LL | struct B< +LL | A: Sized = [(); { LL | let x = [0u8; !0usize]; | ^^^^^^^^^^^^^^ evaluation of `B::{constant#0}` failed here diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr index b232cbf25e751..8d13f6fdccd37 100644 --- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,6 +1,7 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/assign-to-static-within-other-static.rs:8:5 | +LL | static BOO: () = unsafe { LL | FOO = 5; | ^^^^^^^ evaluation of `BOO` failed here diff --git a/tests/ui/consts/const-eval/c-variadic-fail.stderr b/tests/ui/consts/const-eval/c-variadic-fail.stderr index ccf2936324a9c..5a76c882df9aa 100644 --- a/tests/ui/consts/const-eval/c-variadic-fail.stderr +++ b/tests/ui/consts/const-eval/c-variadic-fail.stderr @@ -1,6 +1,8 @@ error[E0080]: more C-variadic arguments read than were passed --> $DIR/c-variadic-fail.rs:27:13 | +LL | unsafe fn read_too_many() { +... LL | const { read_n::<1>() } | ^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#2}` failed inside this call | @@ -29,6 +31,8 @@ LL | const { read_n::<1>() } error[E0080]: more C-variadic arguments read than were passed --> $DIR/c-variadic-fail.rs:31:13 | +LL | unsafe fn read_too_many() { +... LL | const { read_n::<2>(1) } | ^^^^^^^^^^^^^^ evaluation of `read_too_many::{constant#3}` failed inside this call | @@ -57,6 +61,8 @@ LL | const { read_n::<2>(1) } error[E0080]: va_arg value mismatch: value `-1_i32` cannot be represented by type `u32` --> $DIR/c-variadic-fail.rs:71:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(-1i32) }; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#12}` failed inside this call | @@ -85,6 +91,8 @@ LL | const { read_as::(-1i32) }; error[E0080]: va_arg value mismatch: value `-2147483648_i32` cannot be represented by type `u32` --> $DIR/c-variadic-fail.rs:73:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(i32::MIN) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#13}` failed inside this call | @@ -113,6 +121,8 @@ LL | const { read_as::(i32::MIN) }; error[E0080]: va_arg value mismatch: value `4294967295_u32` cannot be represented by type `i32` --> $DIR/c-variadic-fail.rs:75:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#14}` failed inside this call | @@ -141,6 +151,8 @@ LL | const { read_as::(u32::MAX) }; error[E0080]: va_arg value mismatch: value `2147483648_u32` cannot be represented by type `i32` --> $DIR/c-variadic-fail.rs:77:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(i32::MAX as u32 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#15}` failed inside this call | @@ -169,6 +181,8 @@ LL | const { read_as::(i32::MAX as u32 + 1) }; error[E0080]: va_arg value mismatch: value `18446744073709551615_u64` cannot be represented by type `i64` --> $DIR/c-variadic-fail.rs:79:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(u64::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#16}` failed inside this call | @@ -197,6 +211,8 @@ LL | const { read_as::(u64::MAX) }; error[E0080]: va_arg value mismatch: value `9223372036854775808_u64` cannot be represented by type `i64` --> $DIR/c-variadic-fail.rs:81:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(i64::MAX as u64 + 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#17}` failed inside this call | @@ -225,6 +241,8 @@ LL | const { read_as::(i64::MAX as u64 + 1) }; error[E0080]: va_arg type mismatch: requested `i32` is incompatible with next argument of type `u64` --> $DIR/c-variadic-fail.rs:84:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(1u64) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#18}` failed inside this call | @@ -253,6 +271,8 @@ LL | const { read_as::(1u64) }; error[E0080]: va_arg type mismatch: requested `f64` is incompatible with next argument of type `i32` --> $DIR/c-variadic-fail.rs:87:13 | +LL | unsafe fn read_cast_numeric() { +... LL | const { read_as::(1i32) }; | ^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_numeric::{constant#19}` failed inside this call | @@ -281,6 +301,8 @@ LL | const { read_as::(1i32) }; error[E0080]: va_arg type mismatch: requested `*const u16` is incompatible with next argument of type `*const c_void` --> $DIR/c-variadic-fail.rs:110:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#12}` failed inside this call | @@ -309,6 +331,8 @@ LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; error[E0080]: va_arg type mismatch: requested `*const c_void` is incompatible with next argument of type `*const u16` --> $DIR/c-variadic-fail.rs:112:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#13}` failed inside this call | @@ -337,6 +361,8 @@ LL | const { read_as::<*const c_void>(std::ptr::dangling::()) }; error[E0080]: va_arg type mismatch: requested `*const u16` is incompatible with next argument of type `*const i32` --> $DIR/c-variadic-fail.rs:114:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#14}` failed inside this call | @@ -365,6 +391,8 @@ LL | const { read_as::<*const u16>(std::ptr::dangling::()) }; error[E0080]: va_arg type mismatch: requested `*const u8` is incompatible with next argument of type `usize` --> $DIR/c-variadic-fail.rs:117:13 | +LL | unsafe fn read_cast_pointer() { +... LL | const { read_as::<*const u8>(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_pointer::{constant#15}` failed inside this call | @@ -393,6 +421,8 @@ LL | const { read_as::<*const u8>(1usize) }; error[E0080]: va_arg type mismatch: requested `*const fn(&())` is incompatible with next argument of type `*const for<'a> fn(&'a ())` --> $DIR/c-variadic-fail.rs:126:13 | +LL | unsafe fn read_cast_lifetime() { +... LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: fn(&'a ())>()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `read_cast_lifetime::{constant#1}` failed inside this call | @@ -421,6 +451,10 @@ LL | const { read_as::<*const fn(&'static ())>(std::ptr::dangling:: error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/c-variadic-fail.rs:139:13 | +LL | fn use_after_free() { +... +LL | const { +... LL | ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ evaluation of `use_after_free::{constant#0}` failed inside this call | @@ -454,12 +488,17 @@ LL | | }; error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:161:22 | +LL | fn manual_copy_drop() { +... LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_drop::{constant#0}` failed inside this call | note: inside `manual_copy_drop::helper` --> $DIR/c-variadic-fail.rs:158:9 | +LL | fn manual_copy_drop() { +LL | const unsafe extern "C" fn helper(ap: ...) { +... LL | drop(ap); | ^^^^^^^^ note: inside `std::mem::drop::>` @@ -486,12 +525,17 @@ LL | const { unsafe { helper(1, 2, 3) } }; error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:177:22 | +LL | fn manual_copy_forget() { +... LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_forget::{constant#0}` failed inside this call | note: inside `manual_copy_forget::helper` --> $DIR/c-variadic-fail.rs:174:9 | +LL | fn manual_copy_forget() { +LL | const unsafe extern "C" fn helper(ap: ...) { +... LL | drop(ap); | ^^^^^^^^ note: inside `std::mem::drop::>` @@ -518,12 +562,17 @@ LL | const { unsafe { helper(1, 2, 3) } }; error[E0080]: using ALLOC$ID as variable argument list pointer but it does not point to a variable argument list --> $DIR/c-variadic-fail.rs:190:22 | +LL | fn manual_copy_read() { +... LL | const { unsafe { helper(1, 2, 3) } }; | ^^^^^^^^^^^^^^^ evaluation of `manual_copy_read::{constant#0}` failed inside this call | note: inside `manual_copy_read::helper` --> $DIR/c-variadic-fail.rs:187:17 | +LL | fn manual_copy_read() { +LL | const unsafe extern "C" fn helper(mut ap: ...) { +... LL | let _ = ap.next_arg::(); | ^^^^^^^^^^^^^^^^^^^^ note: inside `VaList::<'_>::next_arg::` @@ -546,6 +595,9 @@ LL | const { unsafe { helper(1, 2, 3) } }; error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got null pointer --> $DIR/c-variadic-fail.rs:198:5 | +LL | fn drop_of_invalid() { +LL | const { +... LL | } | ^ evaluation of `drop_of_invalid::{constant#0}` failed inside this call | diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr index aeb88716f1689..387b06b1dacac 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-3.rs:18:11 | +LL | const A_I8_I +LL | : [u32; (i8::MAX as usize) + 1] LL | = [0; (i8::MAX + 1) as usize]; | ^^^^^^^^^^^^^ evaluation of `A_I8_I::{constant#1}` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr index daabb33e0f319..8b9538069eabc 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow-4.rs:11:13 | +LL | const A_I8_T LL | : [u32; (i8::MAX as i8 + 1i8) as usize] | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A_I8_T::{constant#0}` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr index 6ec3fa73cb702..752731ad4e485 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,48 +1,62 @@ error[E0080]: attempt to compute `i8::MIN - 1_i8`, which would overflow --> $DIR/const-eval-overflow2.rs:12:6 | +LL | const VALS_I8: (i8,) = +LL | ( LL | i8::MIN - 1, | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow --> $DIR/const-eval-overflow2.rs:18:6 | +LL | const VALS_I16: (i16,) = +LL | ( LL | i16::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow --> $DIR/const-eval-overflow2.rs:24:6 | +LL | const VALS_I32: (i32,) = +LL | ( LL | i32::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow --> $DIR/const-eval-overflow2.rs:30:6 | +LL | const VALS_I64: (i64,) = +LL | ( LL | i64::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow --> $DIR/const-eval-overflow2.rs:36:6 | +LL | const VALS_U8: (u8,) = +LL | ( LL | u8::MIN - 1, | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow --> $DIR/const-eval-overflow2.rs:41:6 | +LL | const VALS_U16: (u16,) = ( LL | u16::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/const-eval-overflow2.rs:46:6 | +LL | const VALS_U32: (u32,) = ( LL | u32::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow --> $DIR/const-eval-overflow2.rs:52:6 | +LL | const VALS_U64: (u64,) = +LL | ( LL | u64::MIN - 1, | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr index 5b8e559d046f9..508d5db2b1c71 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,48 +1,62 @@ error[E0080]: attempt to compute `i8::MAX + 1_i8`, which would overflow --> $DIR/const-eval-overflow2b.rs:12:6 | +LL | const VALS_I8: (i8,) = +LL | ( LL | i8::MAX + 1, | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow --> $DIR/const-eval-overflow2b.rs:18:6 | +LL | const VALS_I16: (i16,) = +LL | ( LL | i16::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow --> $DIR/const-eval-overflow2b.rs:24:6 | +LL | const VALS_I32: (i32,) = +LL | ( LL | i32::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow --> $DIR/const-eval-overflow2b.rs:30:6 | +LL | const VALS_I64: (i64,) = +LL | ( LL | i64::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow --> $DIR/const-eval-overflow2b.rs:36:6 | +LL | const VALS_U8: (u8,) = +LL | ( LL | u8::MAX + 1, | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow --> $DIR/const-eval-overflow2b.rs:41:6 | +LL | const VALS_U16: (u16,) = ( LL | u16::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow --> $DIR/const-eval-overflow2b.rs:46:6 | +LL | const VALS_U32: (u32,) = ( LL | u32::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow --> $DIR/const-eval-overflow2b.rs:52:6 | +LL | const VALS_U64: (u64,) = +LL | ( LL | u64::MAX + 1, | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr index 99eeadf6b0d35..3a271d8b7667a 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,48 +1,62 @@ error[E0080]: attempt to compute `i8::MIN * 2_i8`, which would overflow --> $DIR/const-eval-overflow2c.rs:12:6 | +LL | const VALS_I8: (i8,) = +LL | ( LL | i8::MIN * 2, | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow --> $DIR/const-eval-overflow2c.rs:18:6 | +LL | const VALS_I16: (i16,) = +LL | ( LL | i16::MIN * 2, | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow --> $DIR/const-eval-overflow2c.rs:24:6 | +LL | const VALS_I32: (i32,) = +LL | ( LL | i32::MIN * 2, | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow --> $DIR/const-eval-overflow2c.rs:30:6 | +LL | const VALS_I64: (i64,) = +LL | ( LL | i64::MIN * 2, | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow --> $DIR/const-eval-overflow2c.rs:36:6 | +LL | const VALS_U8: (u8,) = +LL | ( LL | u8::MAX * 2, | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow --> $DIR/const-eval-overflow2c.rs:41:6 | +LL | const VALS_U16: (u16,) = ( LL | u16::MAX * 2, | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow --> $DIR/const-eval-overflow2c.rs:46:6 | +LL | const VALS_U32: (u32,) = ( LL | u32::MAX * 2, | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow --> $DIR/const-eval-overflow2c.rs:52:6 | +LL | const VALS_U64: (u64,) = +LL | ( LL | u64::MAX * 2, | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr index f68ef6f96988f..5d2e16c69eda5 100644 --- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr +++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr @@ -1,6 +1,7 @@ error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:27:49 | +LL | fn main() { LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_USIZE_UNION` failed here | @@ -10,6 +11,8 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:30:43 | +LL | fn main() { +... LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U8_UNION` failed here | @@ -19,6 +22,8 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_ error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:33:45 | +LL | fn main() { +... LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U16_UNION` failed here | @@ -28,6 +33,8 @@ LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uin error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:36:45 | +LL | fn main() { +... LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U32_UNION` failed here | @@ -37,6 +44,8 @@ LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uin error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:39:45 | +LL | fn main() { +... LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U64_UNION` failed here | @@ -46,6 +55,8 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:42:47 | +LL | fn main() { +... LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here | @@ -56,6 +67,8 @@ LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.u error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:45:43 | +LL | fn main() { +... LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I8_UNION` failed here | @@ -65,6 +78,8 @@ LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:48:45 | +LL | fn main() { +... LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I16_UNION` failed here | @@ -74,6 +89,8 @@ LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:51:45 | +LL | fn main() { +... LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I32_UNION` failed here | @@ -83,6 +100,8 @@ LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:54:45 | +LL | fn main() { +... LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I64_UNION` failed here | @@ -92,6 +111,8 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int error[E0080]: reading memory at ALLOC$ID[0x0..0x10], but memory is uninitialized at [0x8..0x10], and this operation requires initialized memory --> $DIR/const-pointer-values-in-various-types.rs:57:47 | +LL | fn main() { +... LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here | @@ -102,6 +123,8 @@ LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.i error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:60:45 | +LL | fn main() { +... LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F32_UNION` failed here | @@ -111,6 +134,8 @@ LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.flo error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:63:45 | +LL | fn main() { +... LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F64_UNION` failed here | @@ -120,6 +145,8 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:66:47 | +LL | fn main() { +... LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_BOOL_UNION` failed here | @@ -129,6 +156,8 @@ LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.t error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:69:47 | +LL | fn main() { +... LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_CHAR_UNION` failed here | @@ -138,6 +167,8 @@ LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.c error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:72:39 | +LL | fn main() { +... LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U8_UNION` failed here | @@ -147,6 +178,8 @@ LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:75:41 | +LL | fn main() { +... LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U16_UNION` failed here | @@ -156,6 +189,8 @@ LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:78:41 | +LL | fn main() { +... LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U32_UNION` failed here | @@ -165,6 +200,8 @@ LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:81:41 | +LL | fn main() { +... LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U64_UNION` failed here | @@ -174,6 +211,8 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:84:43 | +LL | fn main() { +... LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U128_UNION` failed here | @@ -183,6 +222,8 @@ LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_12 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:87:39 | +LL | fn main() { +... LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I8_UNION` failed here | @@ -192,6 +233,8 @@ LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:90:41 | +LL | fn main() { +... LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I16_UNION` failed here | @@ -201,6 +244,8 @@ LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:93:41 | +LL | fn main() { +... LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I32_UNION` failed here | @@ -210,6 +255,8 @@ LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:96:41 | +LL | fn main() { +... LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I64_UNION` failed here | @@ -219,6 +266,8 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:99:43 | +LL | fn main() { +... LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I128_UNION` failed here | @@ -228,6 +277,8 @@ LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:102:41 | +LL | fn main() { +... LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F32_UNION` failed here | @@ -237,6 +288,8 @@ LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:105:41 | +LL | fn main() { +... LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F64_UNION` failed here | @@ -246,6 +299,8 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:108:43 | +LL | fn main() { +... LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_BOOL_UNION` failed here | @@ -255,6 +310,8 @@ LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_ error[E0080]: unable to turn pointer into integer --> $DIR/const-pointer-values-in-various-types.rs:111:43 | +LL | fn main() { +... LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_CHAR_UNION` failed here | diff --git a/tests/ui/consts/const-eval/do_not_const_check.stderr b/tests/ui/consts/const-eval/do_not_const_check.stderr index 507999df218d1..7b91d75298e06 100644 --- a/tests/ui/consts/const-eval/do_not_const_check.stderr +++ b/tests/ui/consts/const-eval/do_not_const_check.stderr @@ -1,12 +1,14 @@ error[E0080]: calling non-const function `mostly_harmless` --> $DIR/do_not_const_check.rs:9:5 | +LL | const _: () = { LL | mostly_harmless(); | ^^^^^^^^^^^^^^^^^ evaluation of `_` failed here error[E0080]: calling non-const function `integer_min::` --> $DIR/do_not_const_check.rs:22:5 | +LL | const _: () = { LL | integer_min(0, 1); | ^^^^^^^^^^^^^^^^^ evaluation of `_` failed here diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index e9b7f99ee6d99..199716284c235 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -12,6 +12,8 @@ LL | const _X: &'static u8 = unsafe { error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_dangling.rs:23:5 | +LL | const _Y: u8 = unsafe { +... LL | *reference | ^^^^^^^^^^ evaluation of `_Y` failed here diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr index eb73857143877..5514dadc17a94 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr @@ -1,6 +1,8 @@ error[E0080]: memory access failed: ALLOC$ID has been freed, so this pointer is dangling --> $DIR/dealloc_intrinsic_duplicate.rs:9:5 | +LL | const _X: () = unsafe { +... LL | intrinsics::const_deallocate(ptr, 4, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index cc7f14d6ddb35..5c1bee05e619c 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -1,24 +1,32 @@ error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 4 and alignment 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5 | +LL | const _X: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 4, 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 2 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5 | +LL | const _Y: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 2, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here error[E0080]: incorrect layout on deallocation: ALLOC$ID has size 4 and alignment 4, but gave size 3 and alignment 4 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5 | +LL | const _Z: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 3, 4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Z` failed here error[E0080]: invalid align passed to `const_deallocate`: 3 is not a power of 2 --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | +LL | const _W: () = unsafe { +LL | let ptr = intrinsics::const_allocate(4, 4); LL | intrinsics::const_deallocate(ptr, 4, 3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_W` failed here diff --git a/tests/ui/consts/const-eval/heap/make-global-dangling.stderr b/tests/ui/consts/const-eval/heap/make-global-dangling.stderr index 48c2796d0bf21..5d9f1f5e2e8e3 100644 --- a/tests/ui/consts/const-eval/heap/make-global-dangling.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-dangling.stderr @@ -1,12 +1,14 @@ error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got null pointer --> $DIR/make-global-dangling.rs:9:8 | +LL | const Y: &u32 = unsafe { LL | &*(intrinsics::const_make_global(std::ptr::null_mut()) as *const u32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/make-global-dangling.rs:14:8 | +LL | const Z: &u32 = unsafe { LL | &*(intrinsics::const_make_global(std::ptr::dangling_mut()) as *const u32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Z` failed here diff --git a/tests/ui/consts/const-eval/heap/make-global-other.stderr b/tests/ui/consts/const-eval/heap/make-global-other.stderr index f97c25bdc4957..9c34b45f13c96 100644 --- a/tests/ui/consts/const-eval/heap/make-global-other.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-other.stderr @@ -1,6 +1,7 @@ error[E0080]: pointer passed to `const_make_global` does not point to a heap allocation: ALLOC$ID --> $DIR/make-global-other.rs:11:8 | +LL | const Y: &i32 = unsafe { LL | &*(intrinsics::const_make_global(X as *const i32 as *mut u8) as *const i32) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here diff --git a/tests/ui/consts/const-eval/heap/make-global-twice.stderr b/tests/ui/consts/const-eval/heap/make-global-twice.stderr index a499299d5297f..31bb1b13aebaa 100644 --- a/tests/ui/consts/const-eval/heap/make-global-twice.stderr +++ b/tests/ui/consts/const-eval/heap/make-global-twice.stderr @@ -1,6 +1,8 @@ error[E0080]: attempting to call `const_make_global` twice on the same allocation ALLOC$ID --> $DIR/make-global-twice.rs:13:5 | +LL | const Y: &i32 = unsafe { +... LL | intrinsics::const_make_global(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here diff --git a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr index 8e56ff1cbb7c6..c894a9f9121e4 100644 --- a/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr +++ b/tests/ui/consts/const-eval/heap/ptr_made_global_mutated.stderr @@ -1,6 +1,8 @@ error[E0080]: writing to ALLOC$ID which is read-only --> $DIR/ptr_made_global_mutated.rs:10:5 | +LL | const A: &u8 = unsafe { +... LL | *(ptr as *mut u8) = 2; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A` failed here diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 495cc0eb8921b..3f14fd9aa5ef1 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 0 but the index is 0 --> $DIR/index-out-of-bounds-never-type.rs:9:61 | +LL | impl PrintName { LL | const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; | ^^^^^ evaluation of `PrintName::<()>::VOID` failed here diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr index c525fd1c13bed..1f1ec51198c7b 100644 --- a/tests/ui/consts/const-eval/issue-43197.stderr +++ b/tests/ui/consts/const-eval/issue-43197.stderr @@ -1,12 +1,15 @@ error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:6:20 | +LL | fn main() { LL | const X: u32 = 0 - 1; | ^^^^^ evaluation of `main::X` failed here error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow --> $DIR/issue-43197.rs:8:24 | +LL | fn main() { +... LL | const Y: u32 = foo(0 - 1); | ^^^^^ evaluation of `main::Y` failed here diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 7625664f9ed65..cfd5cc4e67433 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/issue-44578.rs:14:24 | +LL | impl Foo for Bar { LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of ` as Foo>::AMT` failed here diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index 6c0d6cf8b2153..2b1901a74f5b3 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | +LL | impl Foo for A { LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ evaluation of ` as Foo<()>>::BAR` failed here diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index 749c9dde1ce19..a812289d1d6cb 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,6 +1,7 @@ error[E0080]: index out of bounds: the length is 3 but the index is 42 --> $DIR/issue-50814-2.rs:17:24 | +LL | impl Foo for A { LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ evaluation of ` as Foo<()>>::BAR` failed here diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 1287c83ae0ff8..1dcde371e99c3 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | +LL | impl Unsigned for Sum { LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ evaluation of ` as Unsigned>::MAX` failed here @@ -13,6 +14,7 @@ LL | &Sum::::MAX error[E0080]: attempt to compute `u8::MAX + u8::MAX`, which would overflow --> $DIR/issue-50814.rs:16:21 | +LL | impl Unsigned for Sum { LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ evaluation of ` as Unsigned>::MAX` failed here | diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index dfc784bc7a4f3..f08456ddb3834 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to divide `1_usize` by zero --> $DIR/auxiliary/post_monomorphization_error.rs:7:17 | +LL | impl ValidateConstImm { +LL | pub(crate) const VALID: () = { LL | let _ = 1 / ((IMM >= MIN && IMM <= MAX) as usize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `post_monomorphization_error::ValidateConstImm::<2, 0, 1>::VALID` failed here diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr index d2c1e4fde9c0e..8f7983e448df0 100644 --- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr +++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr @@ -1,6 +1,8 @@ error[E0080]: `extern type` field does not have a known offset --> $DIR/issue-91827-extern-types-field-offset.rs:38:17 | +LL | const OFFSET: () = unsafe { +... LL | let field = &x.a; | ^^^^ evaluation of `OFFSET` failed here diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr index f8a6fa24a3624..ecfac002f8def 100644 --- a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,6 +1,7 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mod-static-with-const-fn.rs:14:5 | +LL | static BAR: () = unsafe { LL | *FOO.0.get() = 5; | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index 18cf327d9cd40..c1908805b7c92 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/panic-assoc-never-type.rs:9:21 | +LL | impl PrintName { LL | const VOID: ! = panic!(); | ^^^^^^^^ evaluation of `PrintName::VOID` failed here diff --git a/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr b/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr index a9be41f10d410..79d4ebf1a9ec7 100644 --- a/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr +++ b/tests/ui/consts/const-eval/ptr_fragments_mixed.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/ptr_fragments_mixed.rs:19:9 | +LL | const APTR: *const u8 = { +... LL | y | ^ evaluation of `APTR` failed here | @@ -10,6 +12,8 @@ LL | y error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/ptr_fragments_mixed.rs:33:9 | +LL | const BPTR: *const u8 = { +... LL | y | ^ evaluation of `BPTR` failed here | diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index 5769f46022ff1..340074594f952 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -1,18 +1,24 @@ error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:4:16 | +LL | const MISALIGNED_LOAD: () = unsafe { +... LL | let _val = *ptr; | ^^^^ evaluation of `MISALIGNED_LOAD` failed here error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:11:5 | +LL | const MISALIGNED_STORE: () = unsafe { +... LL | *ptr = 0; | ^^^^^^^^ evaluation of `MISALIGNED_STORE` failed here error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/raw-pointer-ub.rs:19:5 | +LL | const MISALIGNED_COPY: () = unsafe { +... LL | y.copy_to_nonoverlapping(&mut z, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MISALIGNED_COPY` failed inside this call | @@ -22,12 +28,16 @@ note: inside `std::ptr::copy_nonoverlapping::` error[E0080]: accessing memory based on pointer with alignment 4, but alignment 16 is required --> $DIR/raw-pointer-ub.rs:33:16 | +LL | const MISALIGNED_FIELD: () = unsafe { +... LL | let _val = (*ptr).0; | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation --> $DIR/raw-pointer-ub.rs:40:16 | +LL | const OOB: () = unsafe { +... LL | let _val = *ptr; | ^^^^ evaluation of `OOB` failed here diff --git a/tests/ui/consts/const-eval/read_partial_ptr.stderr b/tests/ui/consts/const-eval/read_partial_ptr.stderr index c2d220b2e1e21..3f9f08ac6f1a9 100644 --- a/tests/ui/consts/const-eval/read_partial_ptr.stderr +++ b/tests/ui/consts/const-eval/read_partial_ptr.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:10:13 | +LL | const PARTIAL_OVERWRITE: () = { +... LL | let x = *p; | ^^ evaluation of `PARTIAL_OVERWRITE` failed here | @@ -10,6 +12,8 @@ LL | let x = *p; error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:23:13 | +LL | const PTR_BYTES_SWAP: () = { +... LL | let x = *p; | ^^ evaluation of `PTR_BYTES_SWAP` failed here | @@ -19,6 +23,8 @@ LL | let x = *p; error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:34:13 | +LL | const PTR_BYTES_REPEAT: () = { +... LL | let x = *p; | ^^ evaluation of `PTR_BYTES_REPEAT` failed here | @@ -28,6 +34,8 @@ LL | let x = *p; error[E0080]: unable to read parts of a pointer from memory at ALLOC$ID --> $DIR/read_partial_ptr.rs:46:13 | +LL | const PTR_BYTES_MIX: () = { +... LL | let x = *p; | ^^ evaluation of `PTR_BYTES_MIX` failed here | diff --git a/tests/ui/consts/const-eval/shift_overflow.stderr b/tests/ui/consts/const-eval/shift_overflow.stderr index 8c32ddb59081f..8e0efcea6e1ce 100644 --- a/tests/ui/consts/const-eval/shift_overflow.stderr +++ b/tests/ui/consts/const-eval/shift_overflow.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to shift left by `4294967296_u64`, which would overflow --> $DIR/shift_overflow.rs:3:9 | +LL | enum Foo { +LL | // test that we detect overflows for non-u32 discriminants LL | X = 1 << ((u32::MAX as u64) + 1), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Foo::X::{constant#0}` failed here diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr index bda771bd38e88..4563c7ac72dff 100644 --- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr +++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr @@ -1,6 +1,8 @@ error[E0080]: reading memory at ALLOC$ID[0x1..0x2], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/ub-enum-overwrite.rs:11:14 | +LL | const _: u8 = { +... LL | unsafe { *p } | ^^ evaluation of `_` failed here | diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index 8f0b90dcfca75..3694481ba2cec 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -123,6 +123,8 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { error[E0080]: read discriminant of an uninhabited enum variant --> $DIR/ub-enum.rs:105:9 | +LL | const TEST_ICE_89765: () = { +... LL | std::mem::discriminant(&*(&() as *const () as *const Never)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TEST_ICE_89765` failed inside this call | diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr index 3a3b9bc16b850..f4dbdf9ee1462 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.stderr +++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr @@ -1,6 +1,8 @@ error[E0080]: interpreting an invalid 8-bit value as a bool: 0x03 --> $DIR/ub-invalid-values.rs:8:5 | +LL | const _: () = { +LL | let v = 3_u8; LL | bool_cast(&v as *const u8 as *const bool); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index d34425ea79ad9..a8031cf09421e 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -12,6 +12,8 @@ LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC$ID which is only 1 byte from the end of the allocation --> $DIR/ub-nonnull.rs:24:29 | +LL | const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { +... LL | let out_of_bounds_ptr = &(*ptr)[255]; | ^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index f1f219243c385..9824e10af44c5 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -181,6 +181,8 @@ LL | const MAYBE_NULL_FN_PTR: fn() = unsafe { mem::transmute({ error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required --> $DIR/ub-ref-ptr.rs:77:5 | +LL | const UNALIGNED_READ: () = unsafe { +... LL | ptr.read(); | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr index 052ddb527a546..f3e25d3972e00 100644 --- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr @@ -27,6 +27,8 @@ error[E0080]: evaluation panicked: unsafe precondition(s) violated: slice::get_u This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety. --> $DIR/ub-slice-get-unchecked.rs:20:13 | +LL | const INDEX_OOB_MUT: () = unsafe { +LL | let mut array = ARRAY; LL | let _ = array.get_unchecked_mut(9); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `INDEX_OOB_MUT` failed here diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index a1bf930651dba..d9ffc4264a124 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -24,6 +24,8 @@ LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; error[E0080]: constructing invalid value of type !: encountered a value of the never type `!` --> $DIR/ub-uninhabit.rs:31:16 | +LL | const READ_NEVER: () = unsafe { +... LL | let _val = intrinsics::read_via_copy(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_NEVER` failed here diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr index 13b2585d4dc98..5f94f7a038f63 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr @@ -1,12 +1,16 @@ error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:10:5 | +LL | const WRITE_AFTER_CAST: () = unsafe { +... LL | *ptr = 0; | ^^^^^^^^ evaluation of `WRITE_AFTER_CAST` failed here error[E0080]: writing through a pointer that was derived from a shared (immutable) reference --> $DIR/ub-write-through-immutable.rs:16:5 | +LL | const WRITE_AFTER_TRANSMUTE: () = unsafe { +... LL | *ptr = 0; | ^^^^^^^^ evaluation of `WRITE_AFTER_TRANSMUTE` failed here diff --git a/tests/ui/consts/const-eval/union-const-eval-field.stderr b/tests/ui/consts/const-eval/union-const-eval-field.stderr index e86e1fa22a7e5..be688cb9b908e 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-const-eval-field.rs:30:37 | +LL | const fn read_field3() -> Field3 { LL | const FIELD3: Field3 = unsafe { UNION.field3 }; | ^^^^^^^^^^^^ evaluation of `read_field3::FIELD3` failed here | diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr index 6a4927e42d240..48305537a1f88 100644 --- a/tests/ui/consts/const-eval/union-ice.stderr +++ b/tests/ui/consts/const-eval/union-ice.stderr @@ -11,6 +11,8 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:19:17 | +LL | const FIELD_PATH: Struct = Struct { +LL | a: 42, LL | b: unsafe { UNION.field3 }, | ^^^^^^^^^^^^ evaluation of `FIELD_PATH` failed here | @@ -21,6 +23,8 @@ LL | b: unsafe { UNION.field3 }, error[E0080]: reading memory at ALLOC$ID[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> $DIR/union-ice.rs:31:18 | +LL | const FIELD_PATH2: Struct2 = Struct2 { +... LL | unsafe { UNION.field3 }, | ^^^^^^^^^^^^ evaluation of `FIELD_PATH2` failed here | diff --git a/tests/ui/consts/const-len-underflow-subspans.stderr b/tests/ui/consts/const-len-underflow-subspans.stderr index 51825a03db88e..a98a7af31e7a4 100644 --- a/tests/ui/consts/const-len-underflow-subspans.stderr +++ b/tests/ui/consts/const-len-underflow-subspans.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to compute `1_usize - 2_usize`, which would overflow --> $DIR/const-len-underflow-subspans.rs:8:17 | +LL | fn main() { LL | let a: [i8; ONE - TWO] = unimplemented!(); | ^^^^^^^^^ evaluation of `main::{constant#0}` failed here diff --git a/tests/ui/consts/const-ptr-is-null.stderr b/tests/ui/consts/const-ptr-is-null.stderr index b532ed9d4c5fa..f274def63a5d8 100644 --- a/tests/ui/consts/const-ptr-is-null.stderr +++ b/tests/ui/consts/const-ptr-is-null.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: null-ness of this pointer cannot be determined in const context --> $DIR/const-ptr-is-null.rs:22:14 | +LL | const MAYBE_NULL: () = { +... LL | assert!(!ptr.wrapping_sub(512).is_null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MAYBE_NULL` failed inside this call | diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr index 1c514f337817f..8fce264e02b23 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -1,12 +1,14 @@ error[E0080]: constant accesses mutable global memory --> $DIR/const_refs_to_static_fail.rs:14:13 | +LL | const C1_READ: () = unsafe { LL | assert!(*C1.get() == 0); | ^^^^^^^^^ evaluation of `C1_READ` failed here error[E0080]: constant accesses mutable global memory --> $DIR/const_refs_to_static_fail.rs:18:13 | +LL | const C2_READ: () = unsafe { LL | assert!(*C2 == 0); | ^^^ evaluation of `C2_READ` failed here diff --git a/tests/ui/consts/const_transmute_type_id.stderr b/tests/ui/consts/const_transmute_type_id.stderr index 85bd4ea2736a9..aac866e8352ed 100644 --- a/tests/ui/consts/const_transmute_type_id.stderr +++ b/tests/ui/consts/const_transmute_type_id.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to turn pointer into integer --> $DIR/const_transmute_type_id.rs:7:27 | +LL | const _: () = { +LL | let id = TypeId::of::(); LL | let id: u8 = unsafe { (&raw const id).cast::().read() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here | diff --git a/tests/ui/consts/const_transmute_type_id2.stderr b/tests/ui/consts/const_transmute_type_id2.stderr index 9c103c5c2ba6b..d371061230c25 100644 --- a/tests/ui/consts/const_transmute_type_id2.stderr +++ b/tests/ui/consts/const_transmute_type_id2.stderr @@ -1,6 +1,8 @@ error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got [noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_transmute_type_id2.rs:10:13 | +LL | const _: () = { +... LL | assert!(a == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id3.stderr b/tests/ui/consts/const_transmute_type_id3.stderr index 679b048c1ab73..7c77df8fae858 100644 --- a/tests/ui/consts/const_transmute_type_id3.stderr +++ b/tests/ui/consts/const_transmute_type_id3.stderr @@ -1,6 +1,8 @@ error[E0080]: pointer not dereferenceable: pointer must point to some allocation, but got 0x3e7[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/const_transmute_type_id3.rs:15:13 | +LL | const _: () = { +... LL | assert!(a == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id4.stderr b/tests/ui/consts/const_transmute_type_id4.stderr index 4060f086cbac4..46b7e763029eb 100644 --- a/tests/ui/consts/const_transmute_type_id4.stderr +++ b/tests/ui/consts/const_transmute_type_id4.stderr @@ -1,6 +1,8 @@ error[E0080]: invalid `TypeId` value: not all bytes carry type id metadata --> $DIR/const_transmute_type_id4.rs:12:13 | +LL | const _: () = { +... LL | assert!(a == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id5.stderr b/tests/ui/consts/const_transmute_type_id5.stderr index ac057d829562f..8d499c7d8f05e 100644 --- a/tests/ui/consts/const_transmute_type_id5.stderr +++ b/tests/ui/consts/const_transmute_type_id5.stderr @@ -1,6 +1,8 @@ error[E0080]: invalid `TypeId` value: the hash does not match the type id metadata --> $DIR/const_transmute_type_id5.rs:16:13 | +LL | const _: () = { +... LL | assert!(b == b); | ^^^^^^ evaluation of `_` failed inside this call | diff --git a/tests/ui/consts/const_transmute_type_id6.stderr b/tests/ui/consts/const_transmute_type_id6.stderr index fd3ac663505fc..fa1f0a910b275 100644 --- a/tests/ui/consts/const_transmute_type_id6.stderr +++ b/tests/ui/consts/const_transmute_type_id6.stderr @@ -1,6 +1,8 @@ error[E0080]: invalid `TypeId` value: not all bytes carry type id metadata --> $DIR/const_transmute_type_id6.rs:12:5 | +LL | const X: bool = { +... LL | id == id | ^^^^^^^^ evaluation of `X` failed inside this call | diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index 4c56304e4c157..1bcf94d203c82 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -1,24 +1,32 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) --> $DIR/copy-intrinsic.rs:20:5 | +LL | const COPY_OOB_1: () = unsafe { +... LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x28 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/copy-intrinsic.rs:28:5 | +LL | const COPY_OOB_2: () = unsafe { +... LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_2` failed here error[E0080]: overflow computing total size of `copy` --> $DIR/copy-intrinsic.rs:34:5 | +LL | const COPY_SIZE_OVERFLOW: () = unsafe { +... LL | copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_SIZE_OVERFLOW` failed here error[E0080]: overflow computing total size of `copy_nonoverlapping` --> $DIR/copy-intrinsic.rs:39:5 | +LL | const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe { +... LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_NONOVERLAPPING_SIZE_OVERFLOW` failed here diff --git a/tests/ui/consts/eval-enum.stderr b/tests/ui/consts/eval-enum.stderr index d647485bc5dcb..6ed0c069165f7 100644 --- a/tests/ui/consts/eval-enum.stderr +++ b/tests/ui/consts/eval-enum.stderr @@ -1,12 +1,15 @@ error[E0080]: attempt to divide `1_isize` by zero --> $DIR/eval-enum.rs:2:15 | +LL | enum Test { LL | DivZero = 1 / 0, | ^^^^^ evaluation of `Test::DivZero::{constant#0}` failed here error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero --> $DIR/eval-enum.rs:4:15 | +LL | enum Test { +... LL | RemZero = 1 % 0, | ^^^^^ evaluation of `Test::RemZero::{constant#0}` failed here diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr index 870f89733409b..a290d1b82cbed 100644 --- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr +++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr @@ -1,12 +1,14 @@ error[E0080]: constructing invalid value of type bool: encountered 0x03, but expected a boolean --> $DIR/detect-extra-ub.rs:29:20 | +LL | const INVALID_BOOL: () = unsafe { LL | let _x: bool = transmute(3u8); | ^^^^^^^^^^^^^^ evaluation of `INVALID_BOOL` failed here error[E0080]: constructing invalid value of type usize: encountered a pointer, but expected an integer --> $DIR/detect-extra-ub.rs:34:21 | +LL | const INVALID_PTR_IN_INT: () = unsafe { LL | let _x: usize = transmute(&3u8); | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_INT` failed here | @@ -16,6 +18,7 @@ LL | let _x: usize = transmute(&3u8); error[E0080]: constructing invalid value of type PtrSizedEnum: at ., encountered a pointer, but expected an integer --> $DIR/detect-extra-ub.rs:39:28 | +LL | const INVALID_PTR_IN_ENUM: () = unsafe { LL | let _x: PtrSizedEnum = transmute(&3u8); | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_ENUM` failed here | @@ -25,6 +28,8 @@ LL | let _x: PtrSizedEnum = transmute(&3u8); error[E0080]: constructing invalid value of type (usize, usize): at .0, encountered a pointer, but expected an integer --> $DIR/detect-extra-ub.rs:45:30 | +LL | const INVALID_SLICE_TO_USIZE_TRANSMUTE: () = unsafe { +LL | let x: &[u8] = &[0; 32]; LL | let _x: (usize, usize) = transmute(x); | ^^^^^^^^^^^^ evaluation of `INVALID_SLICE_TO_USIZE_TRANSMUTE` failed here | @@ -34,12 +39,14 @@ LL | let _x: (usize, usize) = transmute(x); error[E0080]: constructing invalid value of type &u32: encountered an unaligned reference (required 4 byte alignment but found 1) --> $DIR/detect-extra-ub.rs:50:20 | +LL | const UNALIGNED_PTR: () = unsafe { LL | let _x: &u32 = transmute(&[0u8; 4]); | ^^^^^^^^^^^^^^^^^^^^ evaluation of `UNALIGNED_PTR` failed here error[E0080]: constructing invalid value of type fn(): encountered a maybe-null function pointer --> $DIR/detect-extra-ub.rs:56:20 | +LL | const MAYBE_NULL_FN_PTR: () = unsafe { LL | let _x: fn() = transmute({ | ____________________^ LL | | @@ -52,12 +59,16 @@ LL | | }); error[E0080]: constructing invalid value of type UninhDiscriminant: at ., encountered an uninhabited enum variant --> $DIR/detect-extra-ub.rs:67:13 | +LL | const UNINHABITED_VARIANT: () = unsafe { +... LL | let v = *addr_of!(data).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINHABITED_VARIANT` failed here error[E0080]: constructing invalid value of type [*const u8; 2]: at [0], encountered a partial pointer or a mix of pointers --> $DIR/detect-extra-ub.rs:86:16 | +LL | const PARTIAL_POINTER: () = unsafe { +... LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_POINTER` failed here | @@ -67,6 +78,8 @@ LL | let _val = *(&mem as *const Align as *const [*const u8; 2]); error[E0080]: constructing invalid value of type &[u8]: encountered invalid reference metadata: slice is bigger than largest supported object --> $DIR/detect-extra-ub.rs:100:16 | +LL | const OVERSIZED_REF: () = { unsafe { +LL | let slice: *const [u8] = transmute((1usize, usize::MAX)); LL | let _val = &*slice; | ^^^^^^^ evaluation of `OVERSIZED_REF` failed here diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr index 822c3a5c70dd6..6d7237644a8c3 100644 --- a/tests/ui/consts/issue-64506.stderr +++ b/tests/ui/consts/issue-64506.stderr @@ -1,6 +1,8 @@ error[E0080]: constructing invalid value of type ChildStdin: at .inner, encountered a value of zero-variant enum `AnonPipe` --> $DIR/issue-64506.rs:16:22 | +LL | const FOO: () = { +... LL | let x = unsafe { Foo { b: () }.a }; | ^^^^^^^^^^^^^^^ evaluation of `FOO` failed here diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 140b1861bb42a..af4e3f3fc5352 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,6 +1,8 @@ error[E0080]: unable to turn pointer into integer --> $DIR/issue-miri-1910.rs:7:5 | +LL | const C: () = unsafe { +... LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here | diff --git a/tests/ui/consts/large_const_alloc.stderr b/tests/ui/consts/large_const_alloc.stderr index a0b21555608d8..d07eb64d2325b 100644 --- a/tests/ui/consts/large_const_alloc.stderr +++ b/tests/ui/consts/large_const_alloc.stderr @@ -1,12 +1,15 @@ error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:11:13 | +LL | const FOO: () = { +LL | // 128 TiB, unlikely anyone has that much RAM LL | let x = [0_u8; (1 << 47) - 1]; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO` failed here error[E0080]: tried to allocate more memory than available to compiler --> $DIR/large_const_alloc.rs:16:13 | +LL | static FOO2: () = { LL | let x = [0_u8; (1 << 47) - 1]; | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO2` failed here diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 29f371373aef9..589fc8424c602 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,6 +1,7 @@ error[E0080]: calling non-const function `::drop` --> $DIR/assoc_const.rs:19:31 | +LL | trait Bar> { LL | const F: u32 = (U::X, 42).1; | ^ evaluation of `>::F` failed inside this call | diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index a38fe346da6d7..535f025412add 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -1,6 +1,7 @@ error[E0080]: attempt to divide `100_u32` by zero --> $DIR/assoc_const_2.rs:11:20 | +LL | trait Bar { LL | const F: u32 = 100 / U::X; | ^^^^^^^^^^ evaluation of `>::F` failed here diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr index 25b717660ea0e..5a333e9103e22 100644 --- a/tests/ui/consts/miri_unleashed/box.stderr +++ b/tests/ui/consts/miri_unleashed/box.stderr @@ -1,6 +1,7 @@ error[E0080]: calling non-const function `Box::::new` --> $DIR/box.rs:8:11 | +LL | static TEST_BAD: &mut i32 = { LL | &mut *(Box::new(0)) | ^^^^^^^^^^^^^ evaluation of `TEST_BAD` failed here diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index e718aac5329a4..75aba2e3535c0 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -1,6 +1,8 @@ error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:11:5 | +LL | const MUTATE_INTERIOR_MUT: usize = { +LL | static FOO: AtomicUsize = AtomicUsize::new(0); LL | FOO.fetch_add(1, Ordering::Relaxed) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MUTATE_INTERIOR_MUT` failed inside this call | @@ -16,6 +18,8 @@ note: inside `atomic::atomic_add::` error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static.rs:16:14 | +LL | const READ_INTERIOR_MUT: usize = { +LL | static FOO: AtomicUsize = AtomicUsize::new(0); LL | unsafe { *(&FOO as *const _ as *const usize) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_INTERIOR_MUT` failed here diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 1ec49bff3e894..480240843720d 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -1,6 +1,8 @@ error[E0080]: constant accesses mutable global memory --> $DIR/const_refers_to_static_cross_crate.rs:27:15 | +LL | const U8_MUT3: &u8 = { +LL | unsafe { LL | match static_cross_crate::OPT_ZERO { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `U8_MUT3` failed here diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr index 6e2afda763171..81e203bf19b7e 100644 --- a/tests/ui/consts/miri_unleashed/drop.stderr +++ b/tests/ui/consts/miri_unleashed/drop.stderr @@ -1,6 +1,8 @@ error[E0080]: calling non-const function `::drop` --> $DIR/drop.rs:23:1 | +LL | static TEST_BAD: () = { +LL | let _v: NotConstDestruct = NotConstDestruct; LL | }; | ^ evaluation of `TEST_BAD` failed inside this call | diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr index 57b4f07b2fc88..8b1581dd08061 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.stderr +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -1,12 +1,14 @@ error[E0080]: cannot access extern static `DATA` --> $DIR/extern-static.rs:11:25 | +LL | static TEST_READ: () = { LL | unsafe { let _val = DATA; } | ^^^^ evaluation of `TEST_READ` failed here error[E0080]: cannot access extern static `DATA` --> $DIR/extern-static.rs:15:14 | +LL | static TEST_WRITE: () = { LL | unsafe { DATA = 0; } | ^^^^^^^^ evaluation of `TEST_WRITE` failed here diff --git a/tests/ui/consts/miri_unleashed/inline_asm.stderr b/tests/ui/consts/miri_unleashed/inline_asm.stderr index 49e54825695ee..f8d7387b9d9e3 100644 --- a/tests/ui/consts/miri_unleashed/inline_asm.stderr +++ b/tests/ui/consts/miri_unleashed/inline_asm.stderr @@ -1,6 +1,7 @@ error[E0080]: inline assembly is not supported --> $DIR/inline_asm.rs:10:14 | +LL | static TEST_BAD: () = { LL | unsafe { asm!("nop"); } | ^^^^^^^^^^^ evaluation of `TEST_BAD` failed here diff --git a/tests/ui/consts/miri_unleashed/mutating_global.stderr b/tests/ui/consts/miri_unleashed/mutating_global.stderr index f97f88a4b90a7..b133ead7716aa 100644 --- a/tests/ui/consts/miri_unleashed/mutating_global.stderr +++ b/tests/ui/consts/miri_unleashed/mutating_global.stderr @@ -1,6 +1,8 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/mutating_global.rs:9:9 | +LL | static MUTATING_GLOBAL: () = { +LL | unsafe { LL | GLOBAL = 99 | ^^^^^^^^^^^ evaluation of `MUTATING_GLOBAL` failed here diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr index 661a8de6a15c8..738fd03d92063 100644 --- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr @@ -1,12 +1,15 @@ error[E0080]: exposing pointers is not possible at compile-time --> $DIR/ptr_arith.rs:7:13 | +LL | static PTR_INT_CAST: () = { LL | let x = &0 as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PTR_INT_CAST` failed here error[E0080]: unable to turn pointer into integer --> $DIR/ptr_arith.rs:14:14 | +LL | static PTR_INT_TRANSMUTE: () = unsafe { +LL | let x: usize = std::mem::transmute(&0); LL | let _v = x + 0; | ^ evaluation of `PTR_INT_TRANSMUTE` failed here | diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index 08e069dc3ff3f..089297cb576eb 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -1,12 +1,14 @@ error[E0080]: cannot access thread local static `A` --> $DIR/tls.rs:11:25 | +LL | static TEST_BAD: () = { LL | unsafe { let _val = A; } | ^ evaluation of `TEST_BAD` failed here error[E0080]: cannot access thread local static `A` --> $DIR/tls.rs:19:26 | +LL | static TEST_BAD_REF: () = { LL | unsafe { let _val = &A; } | ^ evaluation of `TEST_BAD_REF` failed here diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index ccba98050e79a..7af55684861bc 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,12 +1,14 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes --> $DIR/missing_span_in_backtrace.rs:16:9 | -16 | / ... ptr::swap_nonoverlapping( -17 | | ... &mut x1 as *mut _ as *mut MaybeUninit, -18 | | ... &mut x2 as *mut _ as *mut MaybeUninit, -19 | | ... 10, -20 | | ... ); - | |_______^ evaluation of `X` failed inside this call +10 | const X: () = { +... +16 | / ptr::swap_nonoverlapping( +17 | | &mut x1 as *mut _ as *mut MaybeUninit, +18 | | &mut x2 as *mut _ as *mut MaybeUninit, +19 | | 10, +20 | | ); + | |_________^ evaluation of `X` failed inside this call | note: inside `swap_nonoverlapping::compiletime::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index e357fd096fdfa..ae00aaec6f974 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -1,6 +1,9 @@ error[E0080]: index out of bounds: the length is 1 but the index is 1 --> $DIR/mono-reachable-invalid-const.rs:8:9 | +LL | impl Bar { +LL | const ASSERT: bool = { +LL | let b = std::convert::identity(1); LL | ["oops"][b]; | ^^^^^^^^^^^ evaluation of `Bar::<0>::ASSERT` failed here diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 558e1ea02c6da..95e1819bad46d 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -1,12 +1,15 @@ error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:20:27 | +LL | pub const DIFFERENT_ALLOC: usize = { +... LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC` failed here error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:26:14 | +LL | pub const NOT_PTR: usize = { LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_PTR` failed inside this call | @@ -16,66 +19,88 @@ note: inside `std::ptr::const_ptr::::offset_from` error[E0080]: exact_div: 1_isize cannot be divided by 2_isize without remainder --> $DIR/offset_from_ub.rs:34:14 | +LL | pub const NOT_MULTIPLE_OF_SIZE: isize = { +... LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_MULTIPLE_OF_SIZE` failed here error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:42:14 | +LL | pub const DIFFERENT_INT: isize = { +... LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_INT` failed here error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation --> $DIR/offset_from_ub.rs:51:14 | +LL | const OUT_OF_BOUNDS_1: isize = { +... LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_1` failed here error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation --> $DIR/offset_from_ub.rs:60:14 | +LL | const OUT_OF_BOUNDS_2: isize = { +... LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_2` failed here error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:69:14 | +LL | pub const DIFFERENT_ALLOC_UNSIGNED: usize = { +... LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC_UNSIGNED` failed here error[E0080]: `ptr_offset_from` called when first pointer is too far ahead of second --> $DIR/offset_from_ub.rs:76:14 | +LL | pub const TOO_FAR_APART1: isize = { +... LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART1` failed here error[E0080]: `ptr_offset_from` called when first pointer is too far before second --> $DIR/offset_from_ub.rs:82:14 | +LL | pub const TOO_FAR_APART2: isize = { +... LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART2` failed here error[E0080]: `ptr_offset_from` called when first pointer is too far before second --> $DIR/offset_from_ub.rs:90:14 | +LL | pub const TOO_FAR_APART3: isize = { +... LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART3` failed here error[E0080]: `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8 --> $DIR/offset_from_ub.rs:97:14 | +LL | const WRONG_ORDER_UNSIGNED: usize = { +... LL | unsafe { ptr_offset_from_unsigned(p, p.add(2)) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `WRONG_ORDER_UNSIGNED` failed here error[E0080]: `ptr_offset_from_unsigned` called when first pointer is too far ahead of second --> $DIR/offset_from_ub.rs:104:14 | +LL | pub const TOO_FAR_APART_UNSIGNED: usize = { +... LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART_UNSIGNED` failed here error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation --> $DIR/offset_from_ub.rs:112:14 | +LL | pub const OFFSET_VERY_FAR1: isize = { +... LL | unsafe { ptr2.offset_from(ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR1` failed inside this call | @@ -85,6 +110,8 @@ note: inside `std::ptr::const_ptr::::offset_from` error[E0080]: `ptr_offset_from` called when first pointer is too far before second --> $DIR/offset_from_ub.rs:118:14 | +LL | pub const OFFSET_VERY_FAR2: isize = { +... LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR2` failed inside this call | diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index 9bf679f8a5348..aef0bed72d892 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -10,6 +10,8 @@ LL | }; error[E0080]: calling non-const function `::drop` --> $DIR/qualif-indirect-mutation-fail.rs:24:1 | +LL | pub const A1: () = { +... LL | }; | ^ evaluation of `A1` failed inside this call | @@ -29,6 +31,8 @@ LL | }; error[E0080]: calling non-const function `::drop` --> $DIR/qualif-indirect-mutation-fail.rs:35:1 | +LL | pub const A2: () = { +... LL | }; | ^ evaluation of `A2` failed inside this call | diff --git a/tests/ui/consts/recursive-static-write.stderr b/tests/ui/consts/recursive-static-write.stderr index f5b5c49317cfc..fe1433b05c298 100644 --- a/tests/ui/consts/recursive-static-write.stderr +++ b/tests/ui/consts/recursive-static-write.stderr @@ -1,12 +1,16 @@ error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-static-write.rs:13:9 | +LL | static S: Foo = Foo { +... LL | (&raw const S.x).cast_mut().write(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `S` failed here error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-static-write.rs:20:9 | +LL | static mut S2: Foo = Foo { +... LL | S2.x = 1; | ^^^^^^^^ evaluation of `S2` failed here diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr index 7d7bbbc5e36c7..263478b4c4770 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr index 7d7bbbc5e36c7..263478b4c4770 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-called-fn.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr index 239e9cb147238..4e257309d3805 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr index 239e9cb147238..4e257309d3805 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-closure.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr index 38e169c97016d..d288535f3d914 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr index 38e169c97016d..d288535f3d914 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-drop.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr index e1a82fd52310b..179d852380121 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr index e1a82fd52310b..179d852380121 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr index 1d2af342a4435..e3d55977c1aa3 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr index 1d2af342a4435..e3d55977c1aa3 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index 42a4ca2fd9d7c..dab9944fb90eb 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `m::Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index 42a4ca2fd9d7c..dab9944fb90eb 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `m::Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr index f253a7cbbee38..79f40eed2789e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr index f253a7cbbee38..79f40eed2789e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fn.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr index b962630ca016c..9216dea4b30fc 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | +LL | impl Late { LL | const FAIL: () = panic!(); | ^^^^^^^^ evaluation of `Late::::FAIL` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr index b962630ca016c..9216dea4b30fc 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | +LL | impl Late { LL | const FAIL: () = panic!(); | ^^^^^^^^ evaluation of `Late::::FAIL` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr index 29e6711153c9e..b709a91b3a918 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr index 29e6711153c9e..b709a91b3a918 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-fnptr.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr index 9f652e26f242f..9535bbb707c36 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr index 9f652e26f242f..9535bbb707c36 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-move.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr index 0c12c0de19747..794277890eabe 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr index 0c12c0de19747..794277890eabe 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-dead-vtable.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index 9f65e4f91be95..d8a9c72f022e8 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index 9f65e4f91be95..d8a9c72f022e8 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/collect-in-promoted-const.rs:9:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr index c9fd476bd8b72..19acde4aac041 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr index c9fd476bd8b72..19acde4aac041 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-const-called-fn.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr index 12c5acd02a490..d50cec24abf4e 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | +LL | pub const FOO: () = unsafe { +... LL | let _x: &'static () = &ub(); | ^^^^ evaluation of `FOO` failed inside this call | diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr index 12c5acd02a490..d50cec24abf4e 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/interpret-in-promoted.rs:15:28 | +LL | pub const FOO: () = unsafe { +... LL | let _x: &'static () = &ub(); | ^^^^ evaluation of `FOO` failed inside this call | diff --git a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr index 8b8d375250d21..cd8351dde5e2b 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr index 8b8d375250d21..cd8351dde5e2b 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/interpret-in-static.rs:8:19 | +LL | impl Fail { LL | const C: () = panic!(); | ^^^^^^^^ evaluation of `Fail::::C` failed here diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.stderr b/tests/ui/consts/slice-index-overflow-issue-130284.stderr index 63c355b4b0f4d..c28c546c0dfb2 100644 --- a/tests/ui/consts/slice-index-overflow-issue-130284.stderr +++ b/tests/ui/consts/slice-index-overflow-issue-130284.stderr @@ -1,6 +1,8 @@ error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` --> $DIR/slice-index-overflow-issue-130284.rs:7:20 | +LL | const C: () = { +... LL | let _ice = (*fat)[usize::MAX - 1]; | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stderr index 556a4d956ed4b..6b67ed1656bf9 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.stderr @@ -1,6 +1,7 @@ error[E0080]: modifying a static's initial value from another static's initializer --> $DIR/static_mut_containing_mut_ref2.rs:6:5 | +LL | pub static mut STDERR_BUFFER: () = unsafe { LL | *(&mut STDERR_BUFFER_SPACE) = 42; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STDERR_BUFFER` failed here diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index cae4f8c33239f..df12f760748b7 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,6 +1,7 @@ error[E0080]: reached the configured maximum number of stack frames --> $DIR/uninhabited-const-issue-61744.rs:13:36 | +LL | trait Const { LL | const CONSTANT: i32 = unsafe { fake_type() }; | ^^^^^^^^^^^ evaluation of `::CONSTANT` failed inside this call | diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr index 73e1578242675..6e0de1071e721 100644 --- a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of ` as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr index 4ce1e2e407e9d..212320a60a1db 100644 --- a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of ` as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr index 5f9b5e3b71edd..a90038f0682b3 100644 --- a/tests/ui/enum-discriminant/eval-error.stderr +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -45,6 +45,8 @@ LL | a: Box, error[E0080]: the type `Foo` has an unknown layout --> $DIR/eval-error.rs:9:30 | +LL | enum Bar { +LL | Boo = { LL | let _: Option = None; | ^^^^ evaluation of `Bar::Boo::{constant#0}` failed here diff --git a/tests/ui/error-codes/E0080.stderr b/tests/ui/error-codes/E0080.stderr index c78454620d18e..1bc7fccbb58c3 100644 --- a/tests/ui/error-codes/E0080.stderr +++ b/tests/ui/error-codes/E0080.stderr @@ -1,12 +1,15 @@ error[E0080]: attempt to shift left by `500_i32`, which would overflow --> $DIR/E0080.rs:2:9 | +LL | enum Enum { LL | X = (1 << 500), | ^^^^^^^^^^ evaluation of `Enum::X::{constant#0}` failed here error[E0080]: attempt to divide `1_isize` by zero --> $DIR/E0080.rs:3:9 | +LL | enum Enum { +LL | X = (1 << 500), LL | Y = (1 / 0), | ^^^^^^^ evaluation of `Enum::Y::{constant#0}` failed here diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr index 5102f278f0273..34da52e79c4df 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr @@ -12,11 +12,17 @@ LL | inner(0, n) note: [... 125 additional calls inside `inner` ...] --> $DIR/ctfe-id-unlimited.rs:17:41 | +LL | const fn rec_id(n: u32) -> u32 { +LL | const fn inner(acc: u32, n: u32) -> u32 { +... LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), | ^^^^^^^^^^^^^^^^^^^^^ note: inside `inner` --> $DIR/ctfe-id-unlimited.rs:17:41 | +LL | const fn rec_id(n: u32) -> u32 { +LL | const fn inner(acc: u32, n: u32) -> u32 { +... LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here diff --git a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr index a9f11ac31c3e8..69949260f30b4 100644 --- a/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-evaluatable-bounds.stderr @@ -1,6 +1,8 @@ error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/unsatisfied-evaluatable-bounds.rs:8:10 | +LL | const POSITIVE: usize = N +LL | where LL | [(); N - 1]:; | ^^^^^ evaluation of `POSITIVE::<0>::{constant#0}` failed here diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 6953414f0c235..eb16778867845 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | +LL | impl F { LL | const V: () = assert!(std::mem::size_of::() == 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::::V` failed here @@ -19,6 +20,7 @@ LL | assert_zst::() error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | +LL | impl F { LL | const V: () = assert!(std::mem::size_of::() == 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `assert_zst::F::::V` failed here diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index 26039ba6d4449..b2f22407e189a 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: assertion failed: std::mem::size_of::() == 0 --> $DIR/const-expr-generic-err.rs:4:13 | +LL | fn foo() { LL | const { assert!(std::mem::size_of::() == 0); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::::{constant#0}` failed here @@ -19,6 +20,7 @@ LL | foo::(); error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow --> $DIR/const-expr-generic-err.rs:8:13 | +LL | fn bar() -> usize { LL | const { N - 1 } | ^^^^^ evaluation of `bar::<0>::{constant#0}` failed here diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr index a517ea2fec0f1..e050a95bd00cd 100644 --- a/tests/ui/inline-const/required-const.stderr +++ b/tests/ui/inline-const/required-const.stderr @@ -1,6 +1,8 @@ error[E0080]: evaluation panicked: explicit panic --> $DIR/required-const.rs:6:17 | +LL | fn foo() { +LL | if false { LL | const { panic!() } | ^^^^^^^^ evaluation of `foo::::{constant#0}` failed here diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr index 268527c0e5bf8..943a555df5e20 100644 --- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr +++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr @@ -1,6 +1,7 @@ error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory --> $DIR/intrinsic-raw_eq-const-bad.rs:5:5 | +LL | const RAW_EQ_PADDING: bool = unsafe { LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PADDING` failed here | @@ -11,6 +12,7 @@ LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) error[E0080]: unable to turn pointer into integer --> $DIR/intrinsic-raw_eq-const-bad.rs:10:5 | +LL | const RAW_EQ_PTR: bool = unsafe { LL | std::intrinsics::raw_eq(&(&0), &(&1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PTR` failed here | @@ -20,6 +22,8 @@ LL | std::intrinsics::raw_eq(&(&0), &(&1)) error[E0080]: accessing memory with alignment 1, but alignment 4 is required --> $DIR/intrinsic-raw_eq-const-bad.rs:17:5 | +LL | const RAW_EQ_NOT_ALIGNED: bool = unsafe { +... LL | std::intrinsics::raw_eq(aref, aref) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_NOT_ALIGNED` failed here diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr index b08e37dbd7472..dbb861d4a3bed 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr @@ -20,6 +20,7 @@ LL | struct MySlice(T); error[E0080]: the type `MySlice<[bool]>` has an unknown layout --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `::ALIGN` failed here diff --git a/tests/ui/layout/too-big-no-dce.stderr b/tests/ui/layout/too-big-no-dce.stderr index a4b01dda0a444..5533602d3f393 100644 --- a/tests/ui/layout/too-big-no-dce.stderr +++ b/tests/ui/layout/too-big-no-dce.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u32; NUMBER]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[u32; NUMBER] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr index cad73b603c1ed..2c26523335209 100644 --- a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr +++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:10 | +LL | fn return_str() +... LL | [(); { let _a: Option = None; 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `return_str::{constant#0}` failed here diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr index 7c382c7a85502..b4be04dbe17da 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.stderr +++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/unknown-when-no-type-parameter.rs:11:10 | +LL | fn foo() +... LL | [(); size_of::<<() as Project>::Assoc>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::{constant#0}` failed here diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr index 888e2574119d6..ff52e5f07e080 100644 --- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr +++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr @@ -1,6 +1,8 @@ error[E0080]: entering unreachable code --> $DIR/unknown-when-ptr-metadata-is-DST.rs:8:10 | +LL | fn return_str() +... LL | [(); { let _a: Option<&str> = None; 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `return_str::{constant#0}` failed here diff --git a/tests/ui/limits/issue-17913.32bit.stderr b/tests/ui/limits/issue-17913.32bit.stderr index 6ddde4b891836..8b109ad703c75 100644 --- a/tests/ui/limits/issue-17913.32bit.stderr +++ b/tests/ui/limits/issue-17913.32bit.stderr @@ -3,6 +3,7 @@ error: values of the type `[&usize; usize::MAX]` are too big for the target arch error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/issue-17913.64bit.stderr b/tests/ui/limits/issue-17913.64bit.stderr index d35d697d5f3f3..8ffa2c1966966 100644 --- a/tests/ui/limits/issue-17913.64bit.stderr +++ b/tests/ui/limits/issue-17913.64bit.stderr @@ -3,6 +3,7 @@ error: values of the type `[&usize; usize::MAX]` are too big for the target arch error[E0080]: values of the type `[&usize; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[&usize; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 994e43854f825..acae67709e6b1 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of `<[u8; usize::MAX] as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/issue-75158-64.stderr b/tests/ui/limits/issue-75158-64.stderr index bab0e1b777c28..6832f04caaac4 100644 --- a/tests/ui/limits/issue-75158-64.stderr +++ b/tests/ui/limits/issue-75158-64.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: evaluation of ` as std::mem::SizedTypeProperties>::SIZE` failed here diff --git a/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr b/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr index c6a53d4face4f..16e4572c83e5b 100644 --- a/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr +++ b/tests/ui/limits/vtable-try-as-dyn.full-debuginfo.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/any.rs:LL:COL + ::: $SRC_DIR/core/src/any.rs:LL:COL | = note: evaluation of `std::any::try_as_dyn::<'_, [u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call note: inside `TypeId::trait_info_of::<'_, dyn Trait>` diff --git a/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr b/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr index c6a53d4face4f..16e4572c83e5b 100644 --- a/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr +++ b/tests/ui/limits/vtable-try-as-dyn.no-debuginfo.stderr @@ -1,5 +1,6 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $SRC_DIR/core/src/any.rs:LL:COL + ::: $SRC_DIR/core/src/any.rs:LL:COL | = note: evaluation of `std::any::try_as_dyn::<'_, [u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call note: inside `TypeId::trait_info_of::<'_, dyn Trait>` diff --git a/tests/ui/reflection/trait_info_of_too_big.stderr b/tests/ui/reflection/trait_info_of_too_big.stderr index 8d8557670e816..c28f7684d2e56 100644 --- a/tests/ui/reflection/trait_info_of_too_big.stderr +++ b/tests/ui/reflection/trait_info_of_too_big.stderr @@ -1,6 +1,7 @@ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/trait_info_of_too_big.rs:14:5 | +LL | const _: () = const { LL | TypeId::of::<[u8; usize::MAX]>().trait_info_of_trait_type_id(TypeId::of::()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | @@ -12,6 +13,7 @@ note: inside `type_info::::size` error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture --> $DIR/trait_info_of_too_big.rs:18:5 | +LL | const _: () = const { LL | TypeId::of::<[u8; usize::MAX]>().trait_info_of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | diff --git a/tests/ui/reflection/variant_index_out_of_bounds.stderr b/tests/ui/reflection/variant_index_out_of_bounds.stderr index 177b662d84b7b..b8f7317d4af7c 100644 --- a/tests/ui/reflection/variant_index_out_of_bounds.stderr +++ b/tests/ui/reflection/variant_index_out_of_bounds.stderr @@ -1,6 +1,7 @@ error[E0080]: indexing out of bounds: the len is 2 but the index is 2 --> $DIR/variant_index_out_of_bounds.rs:8:5 | +LL | const _: () = const { LL | TypeId::of::>().fields(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | @@ -20,6 +21,7 @@ LL | | }; error[E0080]: indexing out of bounds: the len is 0 but the index is 1 --> $DIR/variant_index_out_of_bounds.rs:13:5 | +LL | const _: () = const { LL | TypeId::of::>().field(0, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call | diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index 93d1fce637f2f..2e396c81a688e 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -1,6 +1,7 @@ error[E0080]: evaluation panicked: assertion failed: LANE < 4 --> $DIR/const-err-trumps-simd-err.rs:17:13 | +LL | fn get_elem(a: int8x4_t) -> u8 { LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^ evaluation of `get_elem::<4>::{constant#0}` failed here diff --git a/tests/ui/traits/trivial-const-with-impossible-bounds.stderr b/tests/ui/traits/trivial-const-with-impossible-bounds.stderr index c5cf6626cc7a1..72c7c25f537c0 100644 --- a/tests/ui/traits/trivial-const-with-impossible-bounds.stderr +++ b/tests/ui/traits/trivial-const-with-impossible-bounds.stderr @@ -1,6 +1,7 @@ error[E0080]: entering unreachable code --> $DIR/trivial-const-with-impossible-bounds.rs:5:5 | +LL | impl Dummy where for<'a> &'a mut i32: Copy { LL | const C: usize = 1; | ^^^^^^^^^^^^^^^^^^^ evaluation of `Dummy::C` failed here diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index 5f66d85446d5e..3ddd3a32bca67 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -41,6 +41,10 @@ LL | | }> error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:41:9 | +LL | fn yawning_void_struct() { +... +LL | const _: () = { +... LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation of `yawning_void_struct::_` failed here @@ -67,6 +71,10 @@ LL | | }> error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:61:9 | +LL | fn yawning_void_enum() { +... +LL | const _: () = { +... LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation of `yawning_void_enum::_` failed here @@ -93,6 +101,10 @@ LL | | }> error[E0080]: evaluation panicked: assertion failed: false --> $DIR/uninhabited.rs:83:9 | +LL | fn distant_void() { +... +LL | const _: () = { +... LL | assert!(false); | ^^^^^^^^^^^^^^ evaluation of `distant_void::_` failed here