Skip to content

Commit

Permalink
Don't ice in validation when error body is created
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Feb 9, 2024
1 parent 698a3c7 commit e32c1dd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_const_eval/src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ impl<'tcx> MirPass<'tcx> for Validator {
ty::Closure(..) => Abi::RustCall,
ty::CoroutineClosure(..) => Abi::RustCall,
ty::Coroutine(..) => Abi::Rust,
// No need to do MIR validation on error bodies
ty::Error(_) => return,
_ => {
span_bug!(body.span, "unexpected body ty: {:?} phase {:?}", body_ty, mir_phase)
}
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/mir/validate/error-body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// compile-flags: -Zvalidate-mir

fn _test() {
let x = || 45;
missing();
//~^ ERROR cannot find function `missing` in this scope
}

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/mir/validate/error-body.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0425]: cannot find function `missing` in this scope
--> $DIR/error-body.rs:5:5
|
LL | missing();
| ^^^^^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0425`.

0 comments on commit e32c1dd

Please sign in to comment.