Skip to content

Commit 7dd2818

Browse files
committed
Add tests
1 parent 7356ff7 commit 7dd2818

31 files changed

+583
-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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 Trait {
7+
#[stable(feature = "a", since = "1.1.1" )]
8+
fn foo(&self) {}
9+
}
10+
11+
#[stable(feature = "a", since = "1.1.1" )]
12+
impl Trait for Vec<u32> {
13+
fn foo(&self) {}
14+
}
15+
16+
#[unstable_feature_bound(bar)]
17+
#[unstable(feature = "bar", issue = "none" )]
18+
impl Trait for Vec<u64> {
19+
fn foo(&self) {}
20+
}
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: use of unstable library feature `feat_bar` [E0658]
11+
Moo::foo();
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: use of unstable library feature `feat_bar`
2+
--> $DIR/unstable-feature-bound-two-error.rs:9:5
3+
|
4+
LL | Bar::foo();
5+
| ^^^
6+
|
7+
= help: add `#![feature(feat_bar)]` 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+
= note: required for `Bar` to implement `Foo`
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: use of unstable library feature `feat_moo`
2+
--> $DIR/unstable-feature-cross-crate-exact-symbol.rs:16:5
3+
|
4+
LL | Moo::foo();
5+
| ^^^
6+
|
7+
= help: add `#![feature(feat_moo)]` 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+
= note: required for `Moo` to implement `Foo`
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.
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:use of unstable library feature `feat_moo` [E0658]
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};
6+
7+
/// Bar::foo() should still be usable even if we enable multiple feature.
8+
9+
fn main() {
10+
Bar::foo();
11+
}

0 commit comments

Comments
 (0)