]> git.lizzy.rs Git - rust.git/commitdiff
Fix an ICE in the min_const_fn analysis
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 27 Oct 2018 11:34:35 +0000 (13:34 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 27 Oct 2018 11:34:35 +0000 (13:34 +0200)
src/librustc_mir/transform/qualify_min_const_fn.rs
src/test/ui/consts/single_variant_match_ice.rs [new file with mode: 0644]
src/test/ui/consts/single_variant_match_ice.stderr [new file with mode: 0644]

index 52c557b83d5916979301d743b5f8aa2b4a6091bf..6ab68789c027ba7bbdeb1a1aea580d676979b47d 100644 (file)
@@ -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(),
         )),
@@ -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
diff --git a/src/test/ui/consts/single_variant_match_ice.rs b/src/test/ui/consts/single_variant_match_ice.rs
new file mode 100644 (file)
index 0000000..67a41bc
--- /dev/null
@@ -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() {}
diff --git a/src/test/ui/consts/single_variant_match_ice.stderr b/src/test/ui/consts/single_variant_match_ice.stderr
new file mode 100644 (file)
index 0000000..a0222b0
--- /dev/null
@@ -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
+