Skip to content

Commit 80fd239

Browse files
committed
Tests
1 parent 22c9505 commit 80fd239

15 files changed

+303
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#![allow(internal_features)]
2+
#![feature(staged_api)]
3+
#![feature(impl_stability)]
4+
#![allow(dead_code)]
5+
#![stable(feature = "a", since = "1.1.1" )]
6+
7+
#[stable(feature = "a", since = "1.1.1" )]
8+
pub trait Foo {
9+
#[stable(feature = "a", since = "1.1.1" )]
10+
fn foo();
11+
}
12+
#[stable(feature = "a", since = "1.1.1" )]
13+
pub struct Bar;
14+
#[stable(feature = "a", since = "1.1.1" )]
15+
pub struct Moo;
16+
17+
#[unstable_feature_bound(feat_bar)]
18+
#[unstable(feature = "feat_bar", issue = "none" )]
19+
impl Foo for Bar {
20+
fn foo() {}
21+
}
22+
23+
#[unstable_feature_bound(feat_moo)]
24+
#[unstable(feature = "feat_moo", issue = "none" )]
25+
impl Foo for Moo {
26+
fn foo() {}
27+
}
28+
29+
fn main() {
30+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ aux-build:unstable_feature.rs
2+
extern crate unstable_feature;
3+
use unstable_feature::{Foo, Bar, Moo};
4+
5+
// FIXME: both `feat_bar`` and `feat_moo` are needed to pass this test,
6+
// but the diagnostic only will point out `feat_bar`.
7+
8+
fn main() {
9+
Bar::foo();
10+
//~^ ERROR: type annotations needed: cannot satisfy `unstable feature: `feat_bar``
11+
Moo::foo();
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_bar``
2+
--> $DIR/unstable-feature-bound-two-error.rs:9:5
3+
|
4+
LL | Bar::foo();
5+
| ^^^ cannot satisfy `unstable feature: `feat_bar``
6+
|
7+
= note: required for `Bar` to implement `Foo`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0284`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
2+
--> $DIR/unstable-feature-cross-crate-exact-symbol.rs:16:5
3+
|
4+
LL | Moo::foo();
5+
| ^^^ cannot satisfy `unstable feature: `feat_moo``
6+
|
7+
= note: required for `Moo` to implement `Foo`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0284`.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ aux-build:unstable_feature.rs
2+
//@ revisions: pass fail
3+
//@[pass] check-pass
4+
5+
#![cfg_attr(pass, feature(feat_bar, feat_moo))]
6+
#![cfg_attr(fail, feature(feat_bar))]
7+
8+
extern crate unstable_feature;
9+
use unstable_feature::{Foo, Bar, Moo};
10+
11+
/// To use impls gated by both `feat_foo` and `feat_moo`,
12+
/// both features must be enabled.
13+
14+
fn main() {
15+
Bar::foo();
16+
Moo::foo();
17+
//[fail]~^ ERROR: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ aux-build:unstable_feature.rs
2+
//@ check-pass
3+
#![feature(feat_bar, feat_moo)]
4+
extern crate unstable_feature;
5+
use unstable_feature::{Foo, Bar, Moo};
6+
7+
/// Bar::foo() should still be usable even if we enable multiple feature.
8+
9+
fn main() {
10+
Bar::foo();
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_bar``
2+
--> $DIR/unstable-feature-cross-crate-require-bound.rs:12:5
3+
|
4+
LL | Bar::foo();
5+
| ^^^ cannot satisfy `unstable feature: `feat_bar``
6+
|
7+
= note: required for `Bar` to implement `Foo`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0284`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ aux-build:unstable_feature.rs
2+
//@ revisions: pass fail
3+
//@[pass] check-pass
4+
5+
#![cfg_attr(pass, feature(feat_bar))]
6+
extern crate unstable_feature;
7+
use unstable_feature::{Foo, Bar};
8+
9+
/// #[feature(..)] is required to use unstable impl.
10+
11+
fn main() {
12+
Bar::foo();
13+
//[fail]~^ ERROR: cannot satisfy `unstable feature: `feat_bar``
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
2+
--> $DIR/unstable-feature-exact-symbol.rs:38:5
3+
|
4+
LL | Bar::moo();
5+
| ^^^ cannot satisfy `unstable feature: `feat_moo``
6+
|
7+
note: required for `Bar` to implement `Moo`
8+
--> $DIR/unstable-feature-exact-symbol.rs:30:6
9+
|
10+
LL | #[unstable_feature_bound(feat_moo)]
11+
| ----------------------------------- unsatisfied trait bound introduced here
12+
LL | impl Moo for Bar {
13+
| ^^^ ^^^
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0284`.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//@ revisions: pass fail
2+
//@[pass] check-pass
3+
4+
#![allow(internal_features)]
5+
#![feature(staged_api)]
6+
#![feature(impl_stability)]
7+
#![allow(dead_code)]
8+
#![unstable(feature = "feat_foo", issue = "none" )]
9+
10+
/// In staged-api crate, impl that is marked as unstable with
11+
/// feature name `feat_moo` should not be accessible
12+
/// if only `feat_foo` is enabled.
13+
14+
pub trait Foo {
15+
fn foo();
16+
}
17+
18+
pub trait Moo {
19+
fn moo();
20+
}
21+
22+
pub struct Bar;
23+
24+
#[unstable_feature_bound(feat_foo)]
25+
impl Foo for Bar {
26+
fn foo() {}
27+
}
28+
29+
#[unstable_feature_bound(feat_moo)]
30+
impl Moo for Bar {
31+
fn moo() {}
32+
}
33+
34+
#[cfg_attr(fail, unstable_feature_bound(feat_foo))]
35+
#[cfg_attr(pass, unstable_feature_bound(feat_foo, feat_moo))]
36+
fn bar() {
37+
Bar::foo();
38+
Bar::moo();
39+
//[fail]~^ ERROR cannot satisfy `unstable feature: `feat_moo``
40+
}
41+
42+
fn main() {}

0 commit comments

Comments
 (0)