Skip to content

Commit e32c1dd

Browse files
Don't ice in validation when error body is created
1 parent 698a3c7 commit e32c1dd

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ impl<'tcx> MirPass<'tcx> for Validator {
6060
ty::Closure(..) => Abi::RustCall,
6161
ty::CoroutineClosure(..) => Abi::RustCall,
6262
ty::Coroutine(..) => Abi::Rust,
63+
// No need to do MIR validation on error bodies
64+
ty::Error(_) => return,
6365
_ => {
6466
span_bug!(body.span, "unexpected body ty: {:?} phase {:?}", body_ty, mir_phase)
6567
}

tests/ui/mir/validate/error-body.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-flags: -Zvalidate-mir
2+
3+
fn _test() {
4+
let x = || 45;
5+
missing();
6+
//~^ ERROR cannot find function `missing` in this scope
7+
}
8+
9+
fn main() {}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find function `missing` in this scope
2+
--> $DIR/error-body.rs:5:5
3+
|
4+
LL | missing();
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)