about summary refs log tree commit diff
path: root/tests/ui/unstable-feature-bound
diff options
context:
space:
mode:
authortiif <pekyuan@gmail.com>2025-07-14 13:36:19 +0000
committertiif <pekyuan@gmail.com>2025-07-15 13:48:30 +0000
commitab29256b96660ffd01ab0257588cb6cbd08355a8 (patch)
treea1456295dfdd9de49838bc6c254b8e4ab06e3ef0 /tests/ui/unstable-feature-bound
parent1e5c7b28772bb99b8af4ac350aaabbb28168dc99 (diff)
downloadrust-ab29256b96660ffd01ab0257588cb6cbd08355a8.tar.gz
rust-ab29256b96660ffd01ab0257588cb6cbd08355a8.zip
Make stability attribute not to error when unstable feature bound is in effect
Diffstat (limited to 'tests/ui/unstable-feature-bound')
-rw-r--r--tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.rs35
-rw-r--r--tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.stderr11
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.rs b/tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.rs
new file mode 100644
index 00000000000..99501893ae0
--- /dev/null
+++ b/tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.rs
@@ -0,0 +1,35 @@
+#![allow(internal_features)]
+#![feature(staged_api)]
+#![allow(dead_code)]
+#![stable(feature = "a", since = "1.1.1" )]
+
+/// If #[unstable(..)] and #[unstable_feature_name(..)] have the same feature name,
+/// the error should not be thrown as it can effectively mark an impl as unstable.
+///
+/// If the feature name in #[feature] does not exist in #[unstable_feature_bound(..)]
+/// an error should still be thrown because that feature will not be unstable.
+
+#[stable(feature = "a", since = "1.1.1")]
+trait Moo {}
+#[stable(feature = "a", since = "1.1.1")]
+trait Foo {}
+#[stable(feature = "a", since = "1.1.1")]
+trait Boo {}
+#[stable(feature = "a", since = "1.1.1")]
+pub struct Bar;
+
+
+#[unstable(feature = "feat_moo", issue = "none")]
+#[unstable_feature_bound(feat_foo)] //~^ ERROR: an `#[unstable]` annotation here has no effect
+impl Moo for Bar {}
+
+#[unstable(feature = "feat_foo", issue = "none")]
+#[unstable_feature_bound(feat_foo)]
+impl Foo for Bar {}
+
+
+#[unstable(feature = "feat_foo", issue = "none")]
+#[unstable_feature_bound(feat_foo, feat_bar)]
+impl Boo for Bar {}
+
+fn main() {}
diff --git a/tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.stderr b/tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.stderr
new file mode 100644
index 00000000000..4c8af2bbe56
--- /dev/null
+++ b/tests/ui/unstable-feature-bound/unstable-feature-bound-no-effect.stderr
@@ -0,0 +1,11 @@
+error: an `#[unstable]` annotation here has no effect
+  --> $DIR/unstable-feature-bound-no-effect.rs:22:1
+   |
+LL | #[unstable(feature = "feat_moo", issue = "none")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information
+   = note: `#[deny(ineffective_unstable_trait_impl)]` on by default
+
+error: aborting due to 1 previous error
+