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() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_foo``
2+
--> $DIR/unstable-impl-assoc-type.rs:24:16
3+
|
4+
LL | type Assoc = Self;
5+
| ^^^^ cannot satisfy `unstable feature: `feat_foo``
6+
|
7+
note: required for `Foo` to implement `Bar`
8+
--> $DIR/unstable-impl-assoc-type.rs:20:6
9+
|
10+
LL | #[unstable_feature_bound(feat_foo)]
11+
| ----------------------------------- unsatisfied trait bound introduced here
12+
LL | impl Bar for Foo {}
13+
| ^^^ ^^^
14+
note: required by a bound in `Trait::Assoc`
15+
--> $DIR/unstable-impl-assoc-type.rs:14:17
16+
|
17+
LL | type Assoc: Bar;
18+
| ^^^ required by this bound in `Trait::Assoc`
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0284`.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ revisions: pass fail
2+
//@[pass] check-pass
3+
4+
#![allow(internal_features)]
5+
#![feature(staged_api)]
6+
#![feature(impl_stability)]
7+
#![unstable(feature = "feat_foo", issue = "none" )]
8+
9+
/// FIXME: add a description here.
10+
11+
trait Bar {}
12+
13+
trait Trait {
14+
type Assoc: Bar;
15+
}
16+
17+
struct Foo;
18+
19+
#[unstable_feature_bound(feat_foo)]
20+
impl Bar for Foo {}
21+
22+
#[cfg_attr(pass, unstable_feature_bound(feat_foo))]
23+
impl Trait for Foo {
24+
type Assoc = Self;
25+
//[fail]~^ ERROR: cannot satisfy `unstable feature: `feat_foo``
26+
}
27+
28+
fn main(){}
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_foo``
2+
--> $DIR/unstable-impl-cannot-use-feature.rs:27:5
3+
|
4+
LL | Bar::foo();
5+
| ^^^ cannot satisfy `unstable feature: `feat_foo``
6+
|
7+
note: required for `Bar` to implement `Foo`
8+
--> $DIR/unstable-impl-cannot-use-feature.rs:21:6
9+
|
10+
LL | #[unstable_feature_bound(feat_foo)]
11+
| ----------------------------------- unsatisfied trait bound introduced here
12+
LL | impl Foo 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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
#![cfg_attr(fail, feature(feat_foo))]
11+
12+
/// In staged-api crate, using an unstable impl requires
13+
/// #[unstable_feature_bound(..)], not #[feature(..)].
14+
15+
pub trait Foo {
16+
fn foo();
17+
}
18+
pub struct Bar;
19+
20+
#[unstable_feature_bound(feat_foo)]
21+
impl Foo for Bar {
22+
fn foo() {}
23+
}
24+
25+
#[cfg_attr(pass, unstable_feature_bound(feat_foo))]
26+
fn bar() {
27+
Bar::foo();
28+
//[fail]~^ ERROR: cannot satisfy `unstable feature: `feat_foo``
29+
}
30+
31+
fn main() {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ check-pass
2+
3+
#![allow(internal_features)]
4+
#![feature(staged_api)]
5+
#![feature(impl_stability)]
6+
#![allow(dead_code)]
7+
#![unstable(feature = "feat_foo", issue = "none" )]
8+
9+
/// In staged-api crate, if feat_foo is only needed to use an impl,
10+
/// having both `feat_foo` and `feat_bar` will still make it pass.
11+
12+
pub trait Foo {
13+
fn foo();
14+
}
15+
pub struct Bar;
16+
17+
// Annotate the impl as unstable.
18+
#[unstable_feature_bound(feat_foo)]
19+
impl Foo for Bar {
20+
fn foo() {}
21+
}
22+
23+
#[unstable_feature_bound(feat_foo, feat_bar)]
24+
fn bar() {
25+
Bar::foo();
26+
}
27+
28+
fn main() {}

0 commit comments

Comments
 (0)