Skip to content

Commit 8b9107a

Browse files
committed
Auto merge of #2107 - RalfJung:err, r=RalfJung
test for "erroneous constant used" post-monomorphization error Fixes #2106
2 parents 3b8b6aa + d585b92 commit 8b9107a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/diagnostics.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ pub fn report_error<'tcx, 'mir>(
182182
"Undefined Behavior",
183183
ResourceExhaustion(_) =>
184184
"resource exhaustion",
185-
InvalidProgram(InvalidProgramInfo::AlreadyReported(_) | InvalidProgramInfo::Layout(..)) =>
185+
InvalidProgram(
186+
InvalidProgramInfo::AlreadyReported(_) |
187+
InvalidProgramInfo::Layout(..) |
188+
InvalidProgramInfo::ReferencedConstant
189+
) =>
186190
"post-monomorphization error",
187191
kind =>
188192
bug!("This error should be impossible in Miri: {:?}", kind),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const X: u32 = 5;
2+
const Y: u32 = 6;
3+
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
4+
//~^ERROR any use of this value
5+
//~|WARN previously accepted
6+
7+
fn main() {
8+
println!("{}", FOO); //~ERROR post-monomorphization error
9+
//~|ERROR evaluation of constant value failed
10+
//~|ERROR erroneous constant used
11+
//~|WARN previously accepted
12+
}

0 commit comments

Comments
 (0)