Skip to content

Commit 47d1e07

Browse files
committed
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants. Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) rust-lang/rust#115709: ensuring that all locals are dynamically sized. I didn't expect this to change diagnostics, but it's just cycle errors that change. r? `@oli-obk`
2 parents 8dbfed9 + 810a3c7 commit 47d1e07

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/helpers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
142142
fn eval_path_scalar(&self, path: &[&str]) -> Scalar<Provenance> {
143143
let this = self.eval_context_ref();
144144
let instance = this.resolve_path(path, Namespace::ValueNS);
145-
let cid = GlobalId { instance, promoted: None };
146145
// We don't give a span -- this isn't actually used directly by the program anyway.
147-
let const_val = this.eval_global(cid, None).unwrap_or_else(|err| {
146+
let const_val = this.eval_global(instance).unwrap_or_else(|err| {
148147
panic!("failed to evaluate required Rust item: {path:?}\n{err:?}")
149148
});
150149
this.read_scalar(&const_val)

tests/fail/const-ub-checks.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed
44
LL | ptr.read();
55
| ^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
66

7-
note: erroneous constant used
7+
note: erroneous constant encountered
88
--> $DIR/const-ub-checks.rs:LL:CC
99
|
1010
LL | let _x = UNALIGNED_READ;

tests/fail/erroneous_const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | const VOID: ! = panic!();
66
|
77
= 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)
88

9-
note: erroneous constant used
9+
note: erroneous constant encountered
1010
--> $DIR/erroneous_const.rs:LL:CC
1111
|
1212
LL | let _ = PrintName::<T>::VOID;

tests/fail/erroneous_const2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ error[E0080]: evaluation of constant value failed
44
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
55
| ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow
66

7-
note: erroneous constant used
7+
note: erroneous constant encountered
88
--> $DIR/erroneous_const2.rs:LL:CC
99
|
1010
LL | println!("{}", FOO);
1111
| ^^^
1212

13-
note: erroneous constant used
13+
note: erroneous constant encountered
1414
--> $DIR/erroneous_const2.rs:LL:CC
1515
|
1616
LL | println!("{}", FOO);

0 commit comments

Comments
 (0)