about summary refs log tree commit diff
path: root/tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@users.noreply.github.com>2025-07-21 06:58:10 +0000
committerGitHub <noreply@github.com>2025-07-21 06:58:10 +0000
commit8f67bcf4b0524b2efcbeeae50d393b1b51474237 (patch)
tree17b8a9144bf203d4f3184df4d3e471743bbffe07 /tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs
parent4bbe74bb6cabb1f30775081254614ccda6985d8a (diff)
parentda90db796d0cf39658eac0074c63e5e9ffec2ff2 (diff)
downloadrust-8f67bcf4b0524b2efcbeeae50d393b1b51474237.tar.gz
rust-8f67bcf4b0524b2efcbeeae50d393b1b51474237.zip
Merge pull request #20268 from lnicola/sync-from-rust
minor: Sync from downstream
Diffstat (limited to 'tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs')
-rw-r--r--tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs b/tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs
new file mode 100644
index 00000000000..0da618445fd
--- /dev/null
+++ b/tests/ui/unstable-feature-bound/unstable-impl-cannot-use-feature.rs
@@ -0,0 +1,30 @@
+//@ revisions: pass fail
+//@[pass] check-pass
+
+#![allow(internal_features)]
+#![feature(staged_api)]
+#![allow(dead_code)]
+#![unstable(feature = "feat_foo", issue = "none" )]
+
+#![cfg_attr(fail, feature(feat_foo))]
+
+/// In staged-api crate, using an unstable impl requires
+/// #[unstable_feature_bound(..)], not  #[feature(..)].
+
+pub trait Foo {
+    fn foo();
+}
+pub struct Bar;
+
+#[unstable_feature_bound(feat_foo)]
+impl Foo for Bar {
+    fn foo() {}
+}
+
+#[cfg_attr(pass, unstable_feature_bound(feat_foo))]
+fn bar() {
+    Bar::foo();
+    //[fail]~^ ERROR: unstable feature `feat_foo` is used without being enabled.
+}
+
+fn main() {}