Skip to content

Commit c04893a

Browse files
committed
Fix an ICE in the min_const_fn analysis
1 parent 3e6f30e commit c04893a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/librustc_mir/transform/qualify_min_const_fn.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ fn check_terminator(
317317
check_place(tcx, mir, location, span, PlaceMode::Read)?;
318318
check_operand(tcx, mir, value, span)
319319
},
320-
TerminatorKind::SwitchInt { .. } => Err((
320+
321+
TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
321322
span,
322323
"`if`, `match`, `&&` and `||` are not stable in const fn".into(),
323324
)),
@@ -363,7 +364,7 @@ fn check_terminator(
363364
cleanup: _,
364365
} => check_operand(tcx, mir, cond, span),
365366

366-
| TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => span_bug!(
367+
| TerminatorKind::FalseUnwind { .. } => span_bug!(
367368
terminator.source_info.span,
368369
"min_const_fn encountered `{:#?}`",
369370
terminator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
enum Foo {
2+
Prob,
3+
}
4+
5+
impl Foo {
6+
pub const fn as_val(&self) -> u8 {
7+
use self::Foo::*;
8+
9+
match *self {
10+
Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
11+
}
12+
}
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `if`, `match`, `&&` and `||` are not stable in const fn
2+
--> $DIR/single_variant_match_ice.rs:10:13
3+
|
4+
LL | Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
5+
| ^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)