Skip to content

Commit

Permalink
Don't ICE with inline const errors during MIR build
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Nov 11, 2022
1 parent 742d3f0 commit 93921dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
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,
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/consts/invalid-inline-const-in-match-arm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![allow(incomplete_features)]
#![feature(inline_const_pat)]

fn main() {
match () {
const { (|| {})() } => {}
//~^ ERROR cannot call non-const closure in constants
}
}
12 changes: 12 additions & 0 deletions src/test/ui/consts/invalid-inline-const-in-match-arm.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 93921dd

Please sign in to comment.