summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemy Rakic <remy.rakic@gmail.com>2019-12-05 15:02:41 +0100
committerRemy Rakic <remy.rakic@gmail.com>2019-12-05 15:09:06 +0100
commit4a760c6ea12a1d15334879b40787f6f0a7056d9d (patch)
tree77c18e496ef096c9d0f8748a4dd0825aade22d80
parentlibcore: rnable 2 unstable const fn features (diff)
downloadrust-4a760c6ea12a1d15334879b40787f6f0a7056d9d.tar.gz
rust-4a760c6ea12a1d15334879b40787f6f0a7056d9d.tar.bz2
rust-4a760c6ea12a1d15334879b40787f6f0a7056d9d.tar.xz
add regression test for issue 67053
-rw-r--r--src/test/ui/consts/unstable-const-fn-in-libcore.rs29
-rw-r--r--src/test/ui/consts/unstable-const-fn-in-libcore.stderr22
2 files changed, 51 insertions, 0 deletions
diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.rs b/src/test/ui/consts/unstable-const-fn-in-libcore.rs
new file mode 100644
index 0000000..cad1516
--- /dev/null
+++ b/src/test/ui/consts/unstable-const-fn-in-libcore.rs
@@ -0,0 +1,29 @@
1// This is a non-regression test for const-qualification of unstable items in libcore
2// as explained in issue #67053.
3// const-qualification could miss some `const fn`s if they were unstable and the feature
4// gate was not enabled in libcore.
5
6#![stable(feature = "core", since = "1.6.0")]
7#![feature(const_if_match)]
8#![feature(rustc_const_unstable)]
9#![feature(staged_api)]
10
11enum Opt<T> {
12 Some(T),
13 None,
14}
15
16impl<T> Opt<T> {
17 #[rustc_const_unstable(feature = "foo")]
18 #[stable(feature = "rust1", since = "1.0.0")]
19 const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
20 //~^ ERROR destructors cannot be evaluated at compile-time
21 //~| ERROR destructors cannot be evaluated at compile-time
22 match self {
23 Opt::Some(t) => t,
24 Opt::None => f(), //~ ERROR E0015
25 }
26 }
27}
28
29fn main() {}
diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr
new file mode 100644
index 0000000..a8455ce
--- /dev/null
+++ b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr
@@ -0,0 +1,22 @@
1error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
2 --> $DIR/unstable-const-fn-in-libcore.rs:24:26
3 |
4LL | Opt::None => f(),
5 | ^^^
6
7error[E0493]: destructors cannot be evaluated at compile-time
8 --> $DIR/unstable-const-fn-in-libcore.rs:19:53
9 |
10LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
11 | ^ constant functions cannot evaluate destructors
12
13error[E0493]: destructors cannot be evaluated at compile-time
14 --> $DIR/unstable-const-fn-in-libcore.rs:19:47
15 |
16LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
17 | ^^^^ constant functions cannot evaluate destructors
18
19error: aborting due to 3 previous errors
20
21Some errors have detailed explanations: E0015, E0493.
22For more information about an error, try `rustc --explain E0015`.