about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs22
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/staged-api.rs39
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/staged-api.staged.stderr10
-rw-r--r--src/test/ui/rfc-2632-const-trait-impl/staged-api.stock.stderr18
4 files changed, 89 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs
new file mode 100644
index 00000000000..734ce17001e
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs
@@ -0,0 +1,22 @@
+#![feature(const_trait_impl)]
+#![allow(incomplete_features)]
+
+#![feature(staged_api)]
+#![stable(feature = "rust1", since = "1.0.0")]
+
+#[stable(feature = "rust1", since = "1.0.0")]
+pub trait MyTrait {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    fn func();
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+pub struct Unstable;
+
+#[stable(feature = "rust1", since = "1.0.0")]
+#[rustc_const_unstable(feature = "staged", issue = "none")]
+impl const MyTrait for Unstable {
+    fn func() {
+
+    }
+}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/staged-api.rs b/src/test/ui/rfc-2632-const-trait-impl/staged-api.rs
new file mode 100644
index 00000000000..39a1b6066de
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/staged-api.rs
@@ -0,0 +1,39 @@
+// revisions: stock staged
+#![cfg_attr(staged, feature(staged))]
+
+#![feature(const_trait_impl)]
+#![allow(incomplete_features)]
+
+#![feature(staged_api)]
+#![stable(feature = "rust1", since = "1.0.0")]
+
+// aux-build: staged-api.rs
+extern crate staged_api;
+
+use staged_api::*;
+
+#[stable(feature = "rust1", since = "1.0.0")]
+pub struct Stable;
+
+#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg_attr(staged, rustc_const_stable(feature = "rust1", since = "1.0.0"))]
+// ^ should trigger error with or without the attribute
+impl const MyTrait for Stable {
+    fn func() { //~ ERROR trait methods cannot be stable const fn
+
+    }
+}
+
+fn non_const_context() {
+    Unstable::func();
+    Stable::func();
+}
+
+#[unstable(feature = "none", issue = "none")]
+const fn const_context() {
+    Unstable::func();
+    //[stock]~^ ERROR `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
+    Stable::func();
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/staged-api.staged.stderr b/src/test/ui/rfc-2632-const-trait-impl/staged-api.staged.stderr
new file mode 100644
index 00000000000..d2ff4ce2001
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/staged-api.staged.stderr
@@ -0,0 +1,10 @@
+error: trait methods cannot be stable const fn
+  --> $DIR/staged-api.rs:22:5
+   |
+LL | /     fn func() {
+LL | |
+LL | |     }
+   | |_____^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/rfc-2632-const-trait-impl/staged-api.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/staged-api.stock.stderr
new file mode 100644
index 00000000000..91c5469bd90
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/staged-api.stock.stderr
@@ -0,0 +1,18 @@
+error: trait methods cannot be stable const fn
+  --> $DIR/staged-api.rs:22:5
+   |
+LL | /     fn func() {
+LL | |
+LL | |     }
+   | |_____^
+
+error: `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
+  --> $DIR/staged-api.rs:34:5
+   |
+LL |     Unstable::func();
+   |     ^^^^^^^^^^^^^^^^
+   |
+   = help: add `#![feature(staged)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+