Skip to content

Commit d2d844c

Browse files
committed
Improve rustc_on_unimplemented ui test
1 parent 49e5e4e commit d2d844c

File tree

2 files changed

+86
-53
lines changed

2 files changed

+86
-53
lines changed
Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,73 @@
1-
// ignore-tidy-linelength
2-
1+
#![crate_type = "lib"]
32
#![feature(rustc_attrs)]
4-
53
#![allow(unused)]
64

75
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"]
8-
trait Foo<Bar, Baz, Quux>
9-
{}
6+
trait Foo<Bar, Baz, Quux> {}
107

11-
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"]
8+
#[rustc_on_unimplemented = "a collection of type `{Self}` cannot \
9+
be built from an iterator over elements of type `{A}`"]
1210
trait MyFromIterator<A> {
1311
/// Builds a container with elements from an external iterator.
14-
fn my_from_iter<T: Iterator<Item=A>>(iterator: T) -> Self;
12+
fn my_from_iter<T: Iterator<Item = A>>(iterator: T) -> Self;
1513
}
1614

1715
#[rustc_on_unimplemented]
1816
//~^ ERROR malformed `rustc_on_unimplemented` attribute
19-
trait BadAnnotation1
20-
{}
17+
trait NoContent {}
2118

2219
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
2320
//~^ ERROR cannot find parameter C on this trait
24-
trait BadAnnotation2<A,B>
25-
{}
21+
trait ParameterNotPresent<A, B> {}
2622

2723
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
2824
//~^ ERROR positional format arguments are not allowed here
29-
trait BadAnnotation3<A,B>
30-
{}
25+
trait NoPositionalArgs<A, B> {}
3126

32-
#[rustc_on_unimplemented(lorem="")]
27+
#[rustc_on_unimplemented(lorem = "")]
3328
//~^ ERROR this attribute must have a valid
34-
trait BadAnnotation4 {}
29+
trait EmptyMessage {}
3530

3631
#[rustc_on_unimplemented(lorem(ipsum(dolor)))]
3732
//~^ ERROR this attribute must have a valid
38-
trait BadAnnotation5 {}
33+
trait Invalid {}
3934

40-
#[rustc_on_unimplemented(message="x", message="y")]
35+
#[rustc_on_unimplemented(message = "x", message = "y")]
4136
//~^ ERROR this attribute must have a valid
42-
trait BadAnnotation6 {}
37+
trait DuplicateMessage {}
4338

44-
#[rustc_on_unimplemented(message="x", on(desugared, message="y"))]
39+
#[rustc_on_unimplemented(message = "x", on(desugared, message = "y"))]
4540
//~^ ERROR this attribute must have a valid
46-
trait BadAnnotation7 {}
41+
trait OnInWrongPosition {}
4742

48-
#[rustc_on_unimplemented(on(), message="y")]
43+
#[rustc_on_unimplemented(on(), message = "y")]
4944
//~^ ERROR empty `on`-clause
50-
trait BadAnnotation8 {}
45+
trait NoEmptyOn {}
5146

52-
#[rustc_on_unimplemented(on="x", message="y")]
47+
#[rustc_on_unimplemented(on = "x", message = "y")]
5348
//~^ ERROR this attribute must have a valid
54-
trait BadAnnotation9 {}
49+
trait ExpectedPredicateInOn {}
5550

56-
#[rustc_on_unimplemented(on(x="y"), message="y")]
57-
trait BadAnnotation10 {}
51+
#[rustc_on_unimplemented(on(x = "y"), message = "y")]
52+
trait OnWithoutDirectives {}
5853

59-
#[rustc_on_unimplemented(on(desugared, on(desugared, message="x")), message="y")]
54+
#[rustc_on_unimplemented(on(desugared, on(desugared, message = "x")), message = "y")]
6055
//~^ ERROR this attribute must have a valid
61-
trait BadAnnotation11 {}
56+
trait NoNestedOn {}
6257

63-
pub fn main() {
64-
}
58+
// caught by `OnUnimplementedDirective::parse`, *not* `eval_condition`
59+
#[rustc_on_unimplemented(on("y", message = "y"))]
60+
//~^ ERROR invalid `on`-clause
61+
trait UnsupportedLiteral {}
62+
63+
#[rustc_on_unimplemented(on(not(a, b), message = "y"))]
64+
//~^ ERROR expected 1 cfg-pattern
65+
trait ExpectedOnePattern {}
66+
67+
#[rustc_on_unimplemented(on(thing::What, message = "y"))]
68+
//~^ ERROR `cfg` predicate key must be an identifier
69+
trait KeyMustBeIdentifier {}
70+
71+
#[rustc_on_unimplemented(on(thing::What = "value", message = "y"))]
72+
//~^ ERROR `cfg` predicate key must be an identifier
73+
trait KeyMustBeIdentifier2 {}
Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: malformed `rustc_on_unimplemented` attribute input
2-
--> $DIR/bad-annotation.rs:17:1
2+
--> $DIR/bad-annotation.rs:15:1
33
|
44
LL | #[rustc_on_unimplemented]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -12,72 +12,96 @@ LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*
1212
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1313

1414
error[E0230]: cannot find parameter C on this trait
15-
--> $DIR/bad-annotation.rs:22:90
15+
--> $DIR/bad-annotation.rs:19:90
1616
|
1717
LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
1818
| ^
1919

2020
error[E0231]: positional format arguments are not allowed here
21-
--> $DIR/bad-annotation.rs:27:90
21+
--> $DIR/bad-annotation.rs:23:90
2222
|
2323
LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
2424
| ^
2525

2626
error[E0232]: this attribute must have a valid value
27-
--> $DIR/bad-annotation.rs:32:26
27+
--> $DIR/bad-annotation.rs:27:26
2828
|
29-
LL | #[rustc_on_unimplemented(lorem="")]
30-
| ^^^^^^^^ expected value here
29+
LL | #[rustc_on_unimplemented(lorem = "")]
30+
| ^^^^^^^^^^ expected value here
3131
|
3232
= note: eg `#[rustc_on_unimplemented(message="foo")]`
3333

3434
error[E0232]: this attribute must have a valid value
35-
--> $DIR/bad-annotation.rs:36:26
35+
--> $DIR/bad-annotation.rs:31:26
3636
|
3737
LL | #[rustc_on_unimplemented(lorem(ipsum(dolor)))]
3838
| ^^^^^^^^^^^^^^^^^^^ expected value here
3939
|
4040
= note: eg `#[rustc_on_unimplemented(message="foo")]`
4141

4242
error[E0232]: this attribute must have a valid value
43-
--> $DIR/bad-annotation.rs:40:39
43+
--> $DIR/bad-annotation.rs:35:41
4444
|
45-
LL | #[rustc_on_unimplemented(message="x", message="y")]
46-
| ^^^^^^^^^^^ expected value here
45+
LL | #[rustc_on_unimplemented(message = "x", message = "y")]
46+
| ^^^^^^^^^^^^^ expected value here
4747
|
4848
= note: eg `#[rustc_on_unimplemented(message="foo")]`
4949

5050
error[E0232]: this attribute must have a valid value
51-
--> $DIR/bad-annotation.rs:44:39
51+
--> $DIR/bad-annotation.rs:39:41
5252
|
53-
LL | #[rustc_on_unimplemented(message="x", on(desugared, message="y"))]
54-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
53+
LL | #[rustc_on_unimplemented(message = "x", on(desugared, message = "y"))]
54+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
5555
|
5656
= note: eg `#[rustc_on_unimplemented(message="foo")]`
5757

5858
error[E0232]: empty `on`-clause in `#[rustc_on_unimplemented]`
59-
--> $DIR/bad-annotation.rs:48:26
59+
--> $DIR/bad-annotation.rs:43:26
6060
|
61-
LL | #[rustc_on_unimplemented(on(), message="y")]
61+
LL | #[rustc_on_unimplemented(on(), message = "y")]
6262
| ^^^^ empty on-clause here
6363

6464
error[E0232]: this attribute must have a valid value
65-
--> $DIR/bad-annotation.rs:52:26
65+
--> $DIR/bad-annotation.rs:47:26
6666
|
67-
LL | #[rustc_on_unimplemented(on="x", message="y")]
68-
| ^^^^^^ expected value here
67+
LL | #[rustc_on_unimplemented(on = "x", message = "y")]
68+
| ^^^^^^^^ expected value here
6969
|
7070
= note: eg `#[rustc_on_unimplemented(message="foo")]`
7171

7272
error[E0232]: this attribute must have a valid value
73-
--> $DIR/bad-annotation.rs:59:40
73+
--> $DIR/bad-annotation.rs:54:40
7474
|
75-
LL | #[rustc_on_unimplemented(on(desugared, on(desugared, message="x")), message="y")]
76-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
75+
LL | #[rustc_on_unimplemented(on(desugared, on(desugared, message = "x")), message = "y")]
76+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
7777
|
7878
= note: eg `#[rustc_on_unimplemented(message="foo")]`
7979

80-
error: aborting due to 10 previous errors
80+
error[E0232]: invalid `on`-clause in `#[rustc_on_unimplemented]`
81+
--> $DIR/bad-annotation.rs:59:26
82+
|
83+
LL | #[rustc_on_unimplemented(on("y", message = "y"))]
84+
| ^^^^^^^^^^^^^^^^^^^^^^ invalid on-clause here
85+
86+
error[E0536]: expected 1 cfg-pattern
87+
--> $DIR/bad-annotation.rs:63:29
88+
|
89+
LL | #[rustc_on_unimplemented(on(not(a, b), message = "y"))]
90+
| ^^^^^^^^^
91+
92+
error: `cfg` predicate key must be an identifier
93+
--> $DIR/bad-annotation.rs:67:29
94+
|
95+
LL | #[rustc_on_unimplemented(on(thing::What, message = "y"))]
96+
| ^^^^^^^^^^^
97+
98+
error: `cfg` predicate key must be an identifier
99+
--> $DIR/bad-annotation.rs:71:29
100+
|
101+
LL | #[rustc_on_unimplemented(on(thing::What = "value", message = "y"))]
102+
| ^^^^^^^^^^^
103+
104+
error: aborting due to 14 previous errors
81105

82-
Some errors have detailed explanations: E0230, E0231, E0232.
106+
Some errors have detailed explanations: E0230, E0231, E0232, E0536.
83107
For more information about an error, try `rustc --explain E0230`.

0 commit comments

Comments
 (0)