about summary refs log tree commit diff
path: root/src/test/ui/stability-attribute
diff options
context:
space:
mode:
authorJane Lusby <jlusby@yaah.dev>2022-04-11 18:12:26 -0700
committerJane Losare-Lusby <jlusby@yaah.dev>2022-07-08 21:18:13 +0000
commite7fe5456c53a8cc620a10f6284c366d6de0b7df0 (patch)
treea6602956abf2346184eacb332fe48cefa03afcb8 /src/test/ui/stability-attribute
parent052495d0017e2b18b781bcf0469a048e5051f5c0 (diff)
Support unstable moves via stable in unstable items
Diffstat (limited to 'src/test/ui/stability-attribute')
-rw-r--r--src/test/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs8
-rw-r--r--src/test/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs11
-rw-r--r--src/test/ui/stability-attribute/stable-in-unstable.rs46
-rw-r--r--src/test/ui/stability-attribute/stable-in-unstable.stderr39
4 files changed, 104 insertions, 0 deletions
diff --git a/src/test/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs b/src/test/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs
new file mode 100644
index 00000000000..e45b00f994a
--- /dev/null
+++ b/src/test/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs
@@ -0,0 +1,8 @@
+#![feature(staged_api)]
+#![stable(feature = "stable_test_feature", since = "1.2.0")]
+
+#[unstable(feature = "unstable_test_feature", issue = "1")]
+pub mod new_unstable_module {
+    #[stable(feature = "stable_test_feature", since = "1.2.0")]
+    pub trait OldTrait {}
+}
diff --git a/src/test/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs b/src/test/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs
new file mode 100644
index 00000000000..28ad8c28da1
--- /dev/null
+++ b/src/test/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs
@@ -0,0 +1,11 @@
+#![feature(staged_api)]
+#![feature(unstable_test_feature)]
+#![stable(feature = "stable_test_feature", since = "1.2.0")]
+
+extern crate stable_in_unstable_core;
+
+#[stable(feature = "stable_test_feature", since = "1.2.0")]
+pub mod old_stable_module {
+    #[stable(feature = "stable_test_feature", since = "1.2.0")]
+    pub use stable_in_unstable_core::new_unstable_module::OldTrait;
+}
diff --git a/src/test/ui/stability-attribute/stable-in-unstable.rs b/src/test/ui/stability-attribute/stable-in-unstable.rs
new file mode 100644
index 00000000000..272a1a97234
--- /dev/null
+++ b/src/test/ui/stability-attribute/stable-in-unstable.rs
@@ -0,0 +1,46 @@
+// This test is meant to test that we can have a stable item in an unstable module, and that
+// calling that item through the unstable module is unstable, but that re-exporting it from another
+// crate in a stable module is fine.
+//
+// This is necessary to support moving items from `std` into `core` or `alloc` unstably while still
+// exporting the original stable interface in `std`, such as moving `Error` into `core`.
+//
+// aux-build:stable-in-unstable-core.rs
+// aux-build:stable-in-unstable-std.rs
+#![crate_type = "lib"]
+
+extern crate stable_in_unstable_core;
+extern crate stable_in_unstable_std;
+
+mod isolated1 {
+    use stable_in_unstable_core::new_unstable_module; //~ ERROR use of unstable library feature 'unstable_test_feature'
+    use stable_in_unstable_core::new_unstable_module::OldTrait; //~ ERROR use of unstable library feature 'unstable_test_feature'
+}
+
+mod isolated2 {
+    use stable_in_unstable_std::old_stable_module::OldTrait;
+
+    struct LocalType;
+
+    impl OldTrait for LocalType {}
+}
+
+mod isolated3 {
+    use stable_in_unstable_core::new_unstable_module::OldTrait; //~ ERROR use of unstable library feature 'unstable_test_feature'
+
+    struct LocalType;
+
+    impl OldTrait for LocalType {}
+}
+
+mod isolated4 {
+    struct LocalType;
+
+    impl stable_in_unstable_core::new_unstable_module::OldTrait for LocalType {} //~ ERROR use of unstable library feature 'unstable_test_feature'
+}
+
+mod isolated5 {
+    struct LocalType;
+
+    impl stable_in_unstable_std::old_stable_module::OldTrait for LocalType {}
+}
diff --git a/src/test/ui/stability-attribute/stable-in-unstable.stderr b/src/test/ui/stability-attribute/stable-in-unstable.stderr
new file mode 100644
index 00000000000..e123d83584c
--- /dev/null
+++ b/src/test/ui/stability-attribute/stable-in-unstable.stderr
@@ -0,0 +1,39 @@
+error[E0658]: use of unstable library feature 'unstable_test_feature'
+  --> $DIR/stable-in-unstable.rs:16:9
+   |
+LL |     use stable_in_unstable_core::new_unstable_module;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information
+   = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'unstable_test_feature'
+  --> $DIR/stable-in-unstable.rs:17:9
+   |
+LL |     use stable_in_unstable_core::new_unstable_module::OldTrait;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information
+   = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'unstable_test_feature'
+  --> $DIR/stable-in-unstable.rs:29:9
+   |
+LL |     use stable_in_unstable_core::new_unstable_module::OldTrait;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information
+   = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'unstable_test_feature'
+  --> $DIR/stable-in-unstable.rs:39:10
+   |
+LL |     impl stable_in_unstable_core::new_unstable_module::OldTrait for LocalType {}
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information
+   = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0658`.