Fix an ICE in the min_const_fn analysis
This commit is contained in:
parent
3e6f30ec3e
commit
c04893afbb
3 changed files with 26 additions and 2 deletions
|
@ -317,7 +317,8 @@ fn check_terminator(
|
||||||
check_place(tcx, mir, location, span, PlaceMode::Read)?;
|
check_place(tcx, mir, location, span, PlaceMode::Read)?;
|
||||||
check_operand(tcx, mir, value, span)
|
check_operand(tcx, mir, value, span)
|
||||||
},
|
},
|
||||||
TerminatorKind::SwitchInt { .. } => Err((
|
|
||||||
|
TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
|
||||||
span,
|
span,
|
||||||
"`if`, `match`, `&&` and `||` are not stable in const fn".into(),
|
"`if`, `match`, `&&` and `||` are not stable in const fn".into(),
|
||||||
)),
|
)),
|
||||||
|
@ -363,7 +364,7 @@ fn check_terminator(
|
||||||
cleanup: _,
|
cleanup: _,
|
||||||
} => check_operand(tcx, mir, cond, span),
|
} => check_operand(tcx, mir, cond, span),
|
||||||
|
|
||||||
| TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => span_bug!(
|
| TerminatorKind::FalseUnwind { .. } => span_bug!(
|
||||||
terminator.source_info.span,
|
terminator.source_info.span,
|
||||||
"min_const_fn encountered `{:#?}`",
|
"min_const_fn encountered `{:#?}`",
|
||||||
terminator
|
terminator
|
||||||
|
|
15
src/test/ui/consts/single_variant_match_ice.rs
Normal file
15
src/test/ui/consts/single_variant_match_ice.rs
Normal file
|
@ -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
src/test/ui/consts/single_variant_match_ice.stderr
Normal file
8
src/test/ui/consts/single_variant_match_ice.stderr
Normal file
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue