Skip to content

Commit fd34b00

Browse files
committed
Add tests
1 parent fb5308d commit fd34b00

26 files changed

+473
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![allow(internal_features)]
2+
#![feature(staged_api)]
3+
#![stable(feature = "a", since = "1.1.1" )]
4+
5+
#[stable(feature = "a", since = "1.1.1" )]
6+
pub trait Foo {
7+
#[stable(feature = "a", since = "1.1.1" )]
8+
fn foo();
9+
}
10+
#[stable(feature = "a", since = "1.1.1" )]
11+
pub struct Bar;
12+
#[stable(feature = "a", since = "1.1.1" )]
13+
pub struct Moo;
14+
15+
#[unstable_feature_bound(feat_bar)]
16+
#[unstable(feature = "feat_bar", issue = "none" )]
17+
impl Foo for Bar {
18+
fn foo() {}
19+
}
20+
21+
#[unstable_feature_bound(feat_moo)]
22+
#[unstable(feature = "feat_moo", issue = "none" )]
23+
impl Foo for Moo {
24+
fn foo() {}
25+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(internal_features)]
2+
#![feature(staged_api)]
3+
#![stable(feature = "a", since = "1.1.1" )]
4+
5+
/// Aux crate for unstable impl codegen test.
6+
7+
#[stable(feature = "a", since = "1.1.1" )]
8+
pub trait Trait {
9+
#[stable(feature = "a", since = "1.1.1" )]
10+
fn method(&self);
11+
}
12+
13+
#[unstable_feature_bound(foo)]
14+
#[unstable(feature = "foo", issue = "none" )]
15+
impl<T> Trait for T {
16+
fn method(&self) {
17+
println!("hi");
18+
}
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ aux-build:unstable_impl_codegen_aux1.rs
2+
#![feature(foo)]
3+
4+
extern crate unstable_impl_codegen_aux1 as aux;
5+
use aux::Trait;
6+
7+
/// Upstream crate for unstable impl codegen test
8+
/// that depends on aux crate in
9+
/// unstable_impl_codegen_aux1.rs
10+
11+
pub fn foo<T>(a:T) {
12+
a.method();
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![allow(internal_features)]
2+
#![feature(staged_api)]
3+
#![allow(dead_code)]
4+
#![stable(feature = "a", since = "1.1.1" )]
5+
6+
#[stable(feature = "a", since = "1.1.1" )]
7+
pub trait Trait {}
8+
9+
#[unstable_feature_bound(foo)]
10+
#[unstable(feature = "foo", issue = "none" )]
11+
impl <T> Trait for T {}
12+
13+
fn main() {
14+
}
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`.

0 commit comments

Comments
 (0)