Skip to content

Commit

Permalink
Rollup merge of #104294 - compiler-errors:inline-ct-err-in-mir-build,…
Browse files Browse the repository at this point in the history
… r=davidtwco

Don't ICE with inline const errors during MIR build

Fixes #104277
  • Loading branch information
matthiaskrgr committed Nov 14, 2022
2 parents abda584 + 93921dd commit f8e5b1c
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 f8e5b1c

Please sign in to comment.