diff --git a/src/helpers.rs b/src/helpers.rs index 0c7e827814..72d9dbd045 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -142,9 +142,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { fn eval_path_scalar(&self, path: &[&str]) -> Scalar { let this = self.eval_context_ref(); let instance = this.resolve_path(path, Namespace::ValueNS); - let cid = GlobalId { instance, promoted: None }; // We don't give a span -- this isn't actually used directly by the program anyway. - let const_val = this.eval_global(cid, None).unwrap_or_else(|err| { + let const_val = this.eval_global(instance).unwrap_or_else(|err| { panic!("failed to evaluate required Rust item: {path:?}\n{err:?}") }); this.read_scalar(&const_val) diff --git a/tests/fail/const-ub-checks.stderr b/tests/fail/const-ub-checks.stderr index 596a6bb4ca..d2b9018cd4 100644 --- a/tests/fail/const-ub-checks.stderr +++ b/tests/fail/const-ub-checks.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | ptr.read(); | ^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-ub-checks.rs:LL:CC | LL | let _x = UNALIGNED_READ; diff --git a/tests/fail/erroneous_const.stderr b/tests/fail/erroneous_const.stderr index 209c4a932d..cacf866393 100644 --- a/tests/fail/erroneous_const.stderr +++ b/tests/fail/erroneous_const.stderr @@ -6,7 +6,7 @@ LL | const VOID: ! = panic!(); | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used +note: erroneous constant encountered --> $DIR/erroneous_const.rs:LL:CC | LL | let _ = PrintName::::VOID; diff --git a/tests/fail/erroneous_const2.stderr b/tests/fail/erroneous_const2.stderr index 9aad1fc9b0..36e83b8f3b 100644 --- a/tests/fail/erroneous_const2.stderr +++ b/tests/fail/erroneous_const2.stderr @@ -4,13 +4,13 @@ error[E0080]: evaluation of constant value failed LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow -note: erroneous constant used +note: erroneous constant encountered --> $DIR/erroneous_const2.rs:LL:CC | LL | println!("{}", FOO); | ^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/erroneous_const2.rs:LL:CC | LL | println!("{}", FOO);