about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-01-10 18:48:52 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-01-10 18:51:42 -0800
commit1d418a11913888585d04a322178db28d01300840 (patch)
tree27a3b5d108392935df744518c317768ad2eff2ac
parent09b5c854de112120a6cf4298eb9c96549995b1b0 (diff)
downloadrust-1d418a11913888585d04a322178db28d01300840.tar.gz
rust-1d418a11913888585d04a322178db28d01300840.zip
Test that stable `const fn` requires `allow_internal_unstable`
-rw-r--r--src/test/ui/internal/internal-unstable-const.rs10
-rw-r--r--src/test/ui/internal/internal-unstable-const.stderr12
2 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/internal/internal-unstable-const.rs b/src/test/ui/internal/internal-unstable-const.rs
new file mode 100644
index 00000000000..ce306c84517
--- /dev/null
+++ b/src/test/ui/internal/internal-unstable-const.rs
@@ -0,0 +1,10 @@
+#![feature(staged_api)]
+#![feature(const_if_match)]
+
+#[stable(feature = "rust1", since = "1.0.0")]
+#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
+const fn foo() -> i32 {
+    if true { 4 } else { 5 } //~ loops and conditional expressions are not stable in const fn
+}
+
+fn main() {}
diff --git a/src/test/ui/internal/internal-unstable-const.stderr b/src/test/ui/internal/internal-unstable-const.stderr
new file mode 100644
index 00000000000..58bbe798b00
--- /dev/null
+++ b/src/test/ui/internal/internal-unstable-const.stderr
@@ -0,0 +1,12 @@
+error[E0723]: loops and conditional expressions are not stable in const fn
+  --> $DIR/internal-unstable-const.rs:7:5
+   |
+LL |     if true { 4 } else { 5 }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
+   = help: add `#![feature(const_fn)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0723`.