Skip to content

Commit aa85bc1

Browse files
committed
Combine pass and fail tests
1 parent a86aa75 commit aa85bc1

11 files changed

+67
-35
lines changed

tests/ui/internal/unstable-feature-cross-crate-exact-symbol.stderr renamed to tests/ui/internal/unstable-feature-cross-crate-exact-symbol.fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
2-
--> $DIR/unstable-feature-cross-crate-exact-symbol.rs:11:5
2+
--> $DIR/unstable-feature-cross-crate-exact-symbol.rs:16:5
33
|
44
LL | Moo::foo();
55
| ^^^ cannot satisfy `unstable feature: `feat_moo``
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
//@ aux-build:unstable_feature.rs
2-
#![feature(feat_bar)]
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+
38
extern crate unstable_feature;
49
use unstable_feature::{Foo, Bar, Moo};
510

6-
/// Since only `feat_bar` is enabled, Bar::foo() should be usable and
7-
/// Moo::foo() should not be usable.
11+
/// Both `feat_foo` and `feat_bar` are needed to use impl
12+
/// gated by two different unstable feature bound.
813
914
fn main() {
1015
Bar::foo();
1116
Moo::foo();
12-
//~^ ERROR: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
17+
//[fail]~^ ERROR: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
1318
}

tests/ui/internal/unstable-feature-cross-crate-require-bound.stderr renamed to tests/ui/internal/unstable-feature-cross-crate-require-bound.fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_bar``
2-
--> $DIR/unstable-feature-cross-crate-require-bound.rs:10:5
2+
--> $DIR/unstable-feature-cross-crate-require-bound.rs:12:5
33
|
44
LL | Bar::foo();
55
| ^^^ cannot satisfy `unstable feature: `feat_bar``
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//@ aux-build:unstable_feature.rs
2+
//@ revisions: pass fail
3+
//@[pass] check-pass
24

5+
#![cfg_attr(pass, feature(feat_bar))]
36
extern crate unstable_feature;
47
use unstable_feature::{Foo, Bar};
58

69
/// #[feature(..)] is required to use unstable impl.
7-
/// FIXME: write check-pass variant
810
911
fn main() {
1012
Bar::foo();
11-
//~^ ERROR: cannot satisfy `unstable feature: `feat_bar``
13+
//[fail]~^ ERROR: cannot satisfy `unstable feature: `feat_bar``
1214
}

tests/ui/internal/unstable-feature-exact-symbol.stderr renamed to tests/ui/internal/unstable-feature-exact-symbol.fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_moo``
2-
--> $DIR/unstable-feature-exact-symbol.rs:35:5
2+
--> $DIR/unstable-feature-exact-symbol.rs:37:5
33
|
44
LL | Bar::moo();
55
| ^^^ cannot satisfy `unstable feature: `feat_moo``
66
|
77
note: required for `Bar` to implement `Moo`
8-
--> $DIR/unstable-feature-exact-symbol.rs:28:6
8+
--> $DIR/unstable-feature-exact-symbol.rs:29:6
99
|
1010
LL | #[unstable_feature_bound(feat_moo)]
1111
| ----------------------------------- unsatisfied trait bound introduced here

tests/ui/internal/unstable-feature-exact-symbol.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ revisions: pass fail
2+
//@[pass] check-pass
3+
14
#![allow(internal_features)]
25
#![feature(staged_api)]
36
#![feature(impl_stability)]
@@ -7,8 +10,6 @@
710
/// In staged-api crate, impl that is marked with `feat_moo`
811
/// should not be accessible if only `feat_foo` is enabled.
912
10-
/// FIXME: add one more check pass test with revision?
11-
1213
pub trait Foo {
1314
fn foo();
1415
}
@@ -29,11 +30,12 @@ impl Moo for Bar {
2930
fn moo() {}
3031
}
3132

32-
#[unstable_feature_bound(feat_foo)]
33+
#[cfg_attr(fail, unstable_feature_bound(feat_foo))]
34+
#[cfg_attr(pass, unstable_feature_bound(feat_foo, feat_moo))]
3335
fn bar() {
3436
Bar::foo();
3537
Bar::moo();
36-
//~^ ERROR cannot satisfy `unstable feature: `feat_moo``
38+
//[fail]~^ ERROR cannot satisfy `unstable feature: `feat_moo``
3739
}
3840

3941
fn main() {}

tests/ui/internal/unstable-impl-assoc-type.stderr renamed to tests/ui/internal/unstable-impl-assoc-type.fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ LL | type Assoc = Self;
55
| ^^^^ cannot satisfy `unstable feature: `feat_foo``
66
|
77
note: required for `Foo` to implement `Bar`
8-
--> $DIR/unstable-impl-assoc-type.rs:21:6
8+
--> $DIR/unstable-impl-assoc-type.rs:20:6
99
|
1010
LL | #[unstable_feature_bound(feat_foo)]
1111
| ----------------------------------- unsatisfied trait bound introduced here
1212
LL | impl Bar for Foo {}
1313
| ^^^ ^^^
1414
note: required by a bound in `Trait::Assoc`
15-
--> $DIR/unstable-impl-assoc-type.rs:11:17
15+
--> $DIR/unstable-impl-assoc-type.rs:14:17
1616
|
1717
LL | type Assoc: Bar;
1818
| ^^^ required by this bound in `Trait::Assoc`
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ revisions: pass fail
2+
//@[pass] check-pass
3+
14
#![allow(internal_features)]
25
#![feature(staged_api)]
36
#![feature(impl_stability)]
@@ -11,25 +14,15 @@ trait Trait {
1114
type Assoc: Bar;
1215
}
1316

14-
trait Moo {
15-
type Assoc: Bar;
16-
}
17-
1817
struct Foo;
1918

2019
#[unstable_feature_bound(feat_foo)]
2120
impl Bar for Foo {}
2221

22+
#[cfg_attr(pass, unstable_feature_bound(feat_foo))]
2323
impl Trait for Foo {
2424
type Assoc = Self;
25-
//~^ ERROR: cannot satisfy `unstable feature: `feat_foo``
26-
}
27-
28-
// If the impl is annotated with #[unstable_feature_bound(..)],
29-
// then it should pass.
30-
#[unstable_feature_bound(feat_foo)]
31-
impl Moo for Foo {
32-
type Assoc = Self;
25+
//[fail]~^ ERROR: cannot satisfy `unstable feature: `feat_foo``
3326
}
3427

3528
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() {}

tests/ui/internal/unstable-impl-require-bound.stderr renamed to tests/ui/internal/unstable-impl-require-bound.fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0284]: type annotations needed: cannot satisfy `unstable feature: `feat_foo``
2-
--> $DIR/unstable-impl-require-bound.rs:24:5
2+
--> $DIR/unstable-impl-require-bound.rs:26:5
33
|
44
LL | Bar::foo();
55
| ^^^ cannot satisfy `unstable feature: `feat_foo``
66
|
77
note: required for `Bar` to implement `Foo`
8-
--> $DIR/unstable-impl-require-bound.rs:19:6
8+
--> $DIR/unstable-impl-require-bound.rs:20:6
99
|
1010
LL | #[unstable_feature_bound(feat_foo)]
1111
| ----------------------------------- unsatisfied trait bound introduced here

tests/ui/internal/unstable-impl-require-bound.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
//@ revisions: pass fail
2+
//@[pass] check-pass
3+
14
#![allow(internal_features)]
25
#![feature(staged_api)]
36
#![feature(impl_stability)]
47
#![allow(dead_code)]
58
#![unstable(feature = "feat_foo", issue = "none" )]
69

7-
// This is testing:
8-
// 1. Using an unstable impl requires #[unstable_feature_bound(..)]
9-
// 2. If only feat_foo is needed to use an impl,
10-
// having both `feat_foo` and `feat_bar` will still make it pass.
10+
/// In staged-api crate, using an unstable impl
11+
/// requires #[unstable_feature_bound(..)].
1112
1213
pub trait Foo {
1314
fn foo();
@@ -20,9 +21,10 @@ impl Foo for Bar {
2021
fn foo() {}
2122
}
2223

24+
#[cfg_attr(pass, unstable_feature_bound(feat_foo))]
2325
fn bar() {
2426
Bar::foo();
25-
//~^ ERROR: cannot satisfy `unstable feature: `feat_foo``
27+
//[fail]~^ ERROR: cannot satisfy `unstable feature: `feat_foo``
2628
}
2729

2830
// With #[unstable_feature_bound(..)], this should pass.

0 commit comments

Comments
 (0)