Skip to content

Commit

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

Don't ICE with inline const errors during MIR build

Fixes rust-lang#104277
  • Loading branch information
matthiaskrgr authored Nov 14, 2022
2 parents e242b9d + 93921dd commit daec149
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 daec149

Please sign in to comment.