Skip to content

Commit

Permalink
Auto merge of #2093 - RalfJung:post-mono, r=RalfJung
Browse files Browse the repository at this point in the history
gracefully handle type-too-large layout errors

Fixes #2088
  • Loading branch information
bors committed Apr 30, 2022
2 parents cf5e753 + a0ac13d commit e1068cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ pub fn report_error<'tcx, 'mir>(
"Undefined Behavior",
ResourceExhaustion(_) =>
"resource exhaustion",
InvalidProgram(InvalidProgramInfo::ReferencedConstant) =>
InvalidProgram(InvalidProgramInfo::AlreadyReported(_) | InvalidProgramInfo::Layout(..)) =>
"post-monomorphization error",
InvalidProgram(InvalidProgramInfo::AlreadyReported(_)) =>
"error occurred",
kind =>
bug!("This error should be impossible in Miri: {:?}", kind),
};
Expand Down
2 changes: 1 addition & 1 deletion tests/compile-fail/erroneous_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl<T> PrintName<T> {

fn no_codegen<T>() {
if false {
let _ = PrintName::<T>::VOID; //~ERROR error occurred: encountered constant
let _ = PrintName::<T>::VOID; //~ERROR post-monomorphization error
}
}
fn main() {
Expand Down
6 changes: 6 additions & 0 deletions tests/compile-fail/type-too-large.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ignore-32bit

fn main() {
let _fat: [u8; (1<<61)+(1<<31)] =
[0; (1u64<<61) as usize +(1u64<<31) as usize]; //~ ERROR post-monomorphization error
}

0 comments on commit e1068cf

Please sign in to comment.