Don't ice in validation when error body is created

This commit is contained in:
Michael Goulet 2024-02-09 00:40:43 +00:00
parent 698a3c7ade
commit e32c1ddc52
3 changed files with 20 additions and 0 deletions

View file

@ -60,6 +60,8 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
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)
}

View file

@ -0,0 +1,9 @@
// compile-flags: -Zvalidate-mir
fn _test() {
let x = || 45;
missing();
//~^ ERROR cannot find function `missing` in this scope
}
fn main() {}

View file

@ -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`.