Skip to content

Commit a0ac13d

Browse files
committed
gracefully handle type-too-large layout errors
1 parent cf5e753 commit a0ac13d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/diagnostics.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,8 @@ pub fn report_error<'tcx, 'mir>(
182182
"Undefined Behavior",
183183
ResourceExhaustion(_) =>
184184
"resource exhaustion",
185-
InvalidProgram(InvalidProgramInfo::ReferencedConstant) =>
185+
InvalidProgram(InvalidProgramInfo::AlreadyReported(_) | InvalidProgramInfo::Layout(..)) =>
186186
"post-monomorphization error",
187-
InvalidProgram(InvalidProgramInfo::AlreadyReported(_)) =>
188-
"error occurred",
189187
kind =>
190188
bug!("This error should be impossible in Miri: {:?}", kind),
191189
};

tests/compile-fail/erroneous_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl<T> PrintName<T> {
1212

1313
fn no_codegen<T>() {
1414
if false {
15-
let _ = PrintName::<T>::VOID; //~ERROR error occurred: encountered constant
15+
let _ = PrintName::<T>::VOID; //~ERROR post-monomorphization error
1616
}
1717
}
1818
fn main() {

tests/compile-fail/type-too-large.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ignore-32bit
2+
3+
fn main() {
4+
let _fat: [u8; (1<<61)+(1<<31)] =
5+
[0; (1u64<<61) as usize +(1u64<<31) as usize]; //~ ERROR post-monomorphization error
6+
}

0 commit comments

Comments
 (0)