Skip to content

Commit 6026a16

Browse files
committed
Add a impl_stability gate test
1 parent 108628e commit 6026a16

File tree

5 files changed

+36
-12
lines changed

5 files changed

+36
-12
lines changed

tests/ui/internal/auxiliary/unstable_feature.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#![allow(internal_features)] // Enabled to use #![feature(staged_api)] and #![feature(impl_stability)]
2-
#![feature(staged_api)] // Enabled to use #![unstable(feature = "feat_foo", issue = "none")]
3-
#![feature(impl_stability)] // Enabled to use #[unstable_feature_bound(feat_foo)]
1+
#![allow(internal_features)]
2+
#![feature(staged_api)]
3+
#![feature(impl_stability)]
44
#![allow(dead_code)]
55
#![stable(feature = "a", since = "1.1.1" )]
66

@@ -13,14 +13,14 @@ pub trait Foo {
1313
pub struct Bar;
1414

1515
// Annotate the impl as unstable.
16-
#[unstable_feature_bound(feat_foo)]
16+
#[unstable_feature_bound(feat_foo)]
1717
#[unstable(feature = "feat_foo", issue = "none" )]
1818
impl Foo for Bar {
1919
fn foo() {}
2020
}
2121

2222
// Use the unstable impl inside std/core.
23-
#[unstable_feature_bound(feat_foo)]
23+
#[unstable_feature_bound(feat_foo)]
2424
fn bar() {
2525
Bar::foo();
2626
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// Test for impl_stability gate.
2+
3+
trait Foo{}
4+
struct Bar;
5+
6+
// TODO: make the error message below nicer
7+
#[unstable_feature_bound(feat_foo)]
8+
//~^ ERROR: allow unstable impl
9+
impl Foo for Bar{}
10+
11+
fn main() {
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0658]: allow unstable impl
2+
--> $DIR/unstable-feature-bound-gated.rs:7:1
3+
|
4+
LL | #[unstable_feature_bound(feat_foo)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add `#![feature(impl_stability)]` to the crate attributes to enable
8+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#![allow(internal_features)] // Enabled to use #![feature(staged_api)] and #![feature(impl_stability)]
1+
#![allow(internal_features)]
22
//~^ ERROR: module has missing stability attribute
3-
#![feature(staged_api)] // Enabled to use #![unstable(feature = "feat_foo", issue = "none")]
4-
#![feature(impl_stability)] // Enabled to use #[unstable_feature_bound(feat_foo)]
3+
#![feature(staged_api)]
4+
#![feature(impl_stability)]
55
#![allow(dead_code)]
66

77
#[stable(feature = "a", since = "1.1.1" )]
@@ -13,7 +13,7 @@ pub struct Bar;
1313

1414

1515
// If #[unstable_feature_bound] and #[unstable] has different name,
16-
// It should throw an error.
16+
// It should throw an error.
1717
#[unstable(feature = "feat_moo", issue = "none" )]
1818
#[unstable_feature_bound(feat_foo)] //~^ ERROR: an `#[unstable]` annotation here has no effect
1919
impl Moo for Bar {}
@@ -22,4 +22,4 @@ impl Moo for Bar {}
2222
#[unstable_feature_bound(feat_foo)]
2323
impl Foo for Bar {}
2424

25-
fn main() {}
25+
fn main() {}

tests/ui/internal/unstable-feature-bound.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
extern crate unstable_feature;
44
use unstable_feature::{Foo, Bar};
55

6-
fn main() {
6+
fn main() {
77
Bar::foo(); //~ ERROR: type annotations needed: cannot satisfy `unstable feature: `feat_foo``
8-
}
8+
}

0 commit comments

Comments
 (0)