diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-19 10:40:09 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-19 10:40:09 +0100 |
| commit | 8ee9711a6c00a0994f7fc69586273c86ab45e396 (patch) | |
| tree | 9d1a6b88eb6109e81bd79801427ba92e9412c727 | |
| parent | 7e82eda000c8d4abbdaa76b3563cd77f938fc411 (diff) | |
| download | rust-8ee9711a6c00a0994f7fc69586273c86ab45e396.tar.gz rust-8ee9711a6c00a0994f7fc69586273c86ab45e396.zip | |
Replace the ICEing on const fn loops with an error
| -rw-r--r-- | src/librustc_mir/transform/qualify_min_const_fn.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/consts/min_const_fn/loop_ice.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/consts/min_const_fn/loop_ice.stderr | 8 |
3 files changed, 16 insertions, 5 deletions
diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index ed13063cfdf..958e5efe3ec 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -365,10 +365,8 @@ fn check_terminator( cleanup: _, } => check_operand(tcx, mir, cond, span), - | TerminatorKind::FalseUnwind { .. } => span_bug!( - terminator.source_info.span, - "min_const_fn encountered `{:#?}`", - terminator - ), + TerminatorKind::FalseUnwind { .. } => { + Err((span, "loops are not allowed in const fn".into())) + }, } } diff --git a/src/test/ui/consts/min_const_fn/loop_ice.rs b/src/test/ui/consts/min_const_fn/loop_ice.rs new file mode 100644 index 00000000000..4278a8e2d00 --- /dev/null +++ b/src/test/ui/consts/min_const_fn/loop_ice.rs @@ -0,0 +1,5 @@ +const fn foo() { + loop {} //~ ERROR loops are not allowed in const fn +} + +fn main() {} diff --git a/src/test/ui/consts/min_const_fn/loop_ice.stderr b/src/test/ui/consts/min_const_fn/loop_ice.stderr new file mode 100644 index 00000000000..1424cea65af --- /dev/null +++ b/src/test/ui/consts/min_const_fn/loop_ice.stderr @@ -0,0 +1,8 @@ +error: loops are not allowed in const fn + --> $DIR/loop_ice.rs:2:5 + | +LL | loop {} //~ ERROR loops are not allowed in const fn + | ^^^^^^^ + +error: aborting due to previous error + |
