Skip to content

Commit

Permalink
Rollup merge of rust-lang#55412 - oli-obk:min_const_fn_ice, r=estebank
Browse files Browse the repository at this point in the history
Fix an ICE in the min_const_fn analysis

fixes rust-lang#55395

cc @Centril
  • Loading branch information
Mark-Simulacrum authored Oct 27, 2018
2 parents 545eae8 + c04893a commit 25be4f6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc_mir/transform/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ fn check_terminator(
check_place(tcx, mir, location, span, PlaceMode::Read)?;
check_operand(tcx, mir, value, span)
},
TerminatorKind::SwitchInt { .. } => Err((

TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
span,
"`if`, `match`, `&&` and `||` are not stable in const fn".into(),
)),
Expand Down Expand Up @@ -363,7 +364,7 @@ fn check_terminator(
cleanup: _,
} => check_operand(tcx, mir, cond, span),

| TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => span_bug!(
| TerminatorKind::FalseUnwind { .. } => span_bug!(
terminator.source_info.span,
"min_const_fn encountered `{:#?}`",
terminator
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/consts/single_variant_match_ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
enum Foo {
Prob,
}

impl Foo {
pub const fn as_val(&self) -> u8 {
use self::Foo::*;

match *self {
Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
}
}
}

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/consts/single_variant_match_ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: `if`, `match`, `&&` and `||` are not stable in const fn
--> $DIR/single_variant_match_ice.rs:10:13
|
LL | Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
| ^^^^

error: aborting due to previous error

0 comments on commit 25be4f6

Please sign in to comment.