From 64172481da44e0dd6a705afcea22b58b45b42c5a Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 4 Jun 2025 08:12:54 +0000 Subject: [PATCH] Report the actual item that evaluation failed for --- compiler/rustc_const_eval/src/const_eval/eval_queries.rs | 5 +++-- tests/ui/consts/miri_unleashed/assoc_const.stderr | 2 +- tests/ui/consts/uninhabited-const-issue-61744.rs | 1 + tests/ui/consts/uninhabited-const-issue-61744.stderr | 2 +- 4 files changed, 6 insertions(+), 4 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 01625b91353b7..2556e57a58f33 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -454,11 +454,12 @@ fn report_eval_error<'tcx>( // FIXME(oli-obk): figure out how to use structured diagnostics again. diag.code(E0080); diag.span_label(span, crate::fluent_generated::const_eval_error); - diag.arg("instance", instance); - diag.arg("error_kind", kind); for frame in frames { diag.subdiagnostic(frame); } + // Add after the frame rendering above, as it adds its own `instance` args. + diag.arg("instance", instance); + diag.arg("error_kind", kind); }, ) } diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index b6dcb86f360fd..e843615bd6de7 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -2,7 +2,7 @@ error[E0080]: calling non-const function ` as Drop>::drop` --> $DIR/assoc_const.rs:12:31 | LL | const F: u32 = (U::X, 42).1; - | ^ evaluation of `drop_in_place::> - shim(Some(Vec))` failed here + | ^ evaluation of `, std::string::String>>::F` failed here | note: inside `drop_in_place::<(Vec, u32)> - shim(Some((Vec, u32)))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs index d33f9c268a51f..698245b5cb8ce 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -11,6 +11,7 @@ pub const unsafe fn hint_unreachable() -> ! { trait Const { const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR reached the configured maximum number of stack frames + //~^ NOTE evaluation of `::CONSTANT` failed here } impl Const for T {} diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index 3c5b5196aebf8..f13f6126e9444 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -2,7 +2,7 @@ error[E0080]: reached the configured maximum number of stack frames --> $DIR/uninhabited-const-issue-61744.rs:13:36 | LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ^^^^^^^^^^^ evaluation of `fake_type::` failed here + | ^^^^^^^^^^^ evaluation of `::CONSTANT` failed here | note: inside `fake_type::` --> $DIR/uninhabited-const-issue-61744.rs:5:5