Rollup merge of #104294 - compiler-errors:inline-ct-err-in-mir-build, r=davidtwco

Don't ICE with inline const errors during MIR build

Fixes #104277
This commit is contained in:
Matthias Krüger 2022-11-14 19:26:17 +01:00 committed by GitHub
commit f8e5b1ce9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View file

@ -577,6 +577,9 @@ fn lower_inline_const(
self.errors.push(PatternError::ConstParamInPattern(span));
return PatKind::Wild;
}
ConstKind::Error(_) => {
return PatKind::Wild;
}
_ => bug!("Expected ConstKind::Param"),
},
mir::ConstantKind::Val(_, _) => self.const_to_pat(value, id, span, false).kind,

View file

@ -0,0 +1,9 @@
#![allow(incomplete_features)]
#![feature(inline_const_pat)]
fn main() {
match () {
const { (|| {})() } => {}
//~^ ERROR cannot call non-const closure in constants
}
}

View file

@ -0,0 +1,12 @@
error[E0015]: cannot call non-const closure in constants
--> $DIR/invalid-inline-const-in-match-arm.rs:6:17
|
LL | const { (|| {})() } => {}
| ^^^^^^^^^
|
= note: closures need an RFC before allowed to be called in constants
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error
For more information about this error, try `rustc --explain E0015`.