Skip to content

Commit fd7c253

Browse files
author
Alexander Regueiro
committed
Update tests.
1 parent aea954b commit fd7c253

38 files changed

+1259
-60
lines changed

src/test/ui/associated-types/associated-types-overridden-binding-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | let _: &I32Iterator<Item = u32> = &vec![42].into_iter();
66
|
77
= note: expected type `u32`
88
found type `i32`
9-
= note: required for the cast to the object type `dyn I32Iterator<Item = u32, Item = i32>`
9+
= note: required for the cast to the object type `dyn std::iter::Iterator<Item = u32, Item = i32>`
1010

1111
error: aborting due to previous error
1212

src/test/ui/bad/bad-sized.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0225]: only auto traits can be used as additional traits in a trait objec
22
--> $DIR/bad-sized.rs:4:24
33
|
44
LL | let x: Vec<Trait + Sized> = Vec::new();
5-
| ^^^^^ non-auto additional trait
5+
| ----- ^^^^^ additional non-auto trait
6+
| |
7+
| first non-auto trait
68

79
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
810
--> $DIR/bad-sized.rs:4:12

src/test/ui/error-codes/E0225.stderr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ error[E0225]: only auto traits can be used as additional traits in a trait objec
22
--> $DIR/E0225.rs:6:32
33
|
44
LL | let _: Box<std::io::Read + std::io::Write>;
5-
| ^^^^^^^^^^^^^^ non-auto additional trait
5+
| ------------- ^^^^^^^^^^^^^^ additional non-auto trait
6+
| |
7+
| first non-auto trait
68

79
error[E0225]: only auto traits can be used as additional traits in a trait object
810
--> $DIR/E0225.rs:8:16
911
|
1012
LL | trait Foo = std::io::Read + std::io::Write;
11-
| -------------- non-auto additional trait
13+
| ------------- -------------- additional non-auto trait
14+
| |
15+
| first non-auto trait
1216
...
1317
LL | let _: Box<Foo>;
14-
| ^^^ expanded from this alias
18+
| ^^^
1519

1620
error: aborting due to 2 previous errors
1721

src/test/ui/issues/issue-22560.stderr

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
error[E0393]: the type parameter `Rhs` must be explicitly specified
2-
--> $DIR/issue-22560.rs:3:13
2+
--> $DIR/issue-22560.rs:6:13
33
|
4-
LL | type Test = Add +
4+
LL | Sub;
55
| ^^^ missing reference to `Rhs`
66
|
77
= note: because of the default `Self` reference, type parameters must be specified on object types
88

99
error[E0393]: the type parameter `Rhs` must be explicitly specified
10-
--> $DIR/issue-22560.rs:6:13
10+
--> $DIR/issue-22560.rs:3:13
1111
|
12-
LL | Sub;
12+
LL | type Test = Add +
1313
| ^^^ missing reference to `Rhs`
1414
|
1515
= note: because of the default `Self` reference, type parameters must be specified on object types
1616

1717
error[E0225]: only auto traits can be used as additional traits in a trait object
1818
--> $DIR/issue-22560.rs:6:13
1919
|
20+
LL | type Test = Add +
21+
| --- first non-auto trait
22+
...
2023
LL | Sub;
21-
| ^^^ non-auto additional trait
24+
| ^^^ additional non-auto trait
2225

23-
error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified
26+
error[E0191]: the value of the associated types `Output` (from the trait `std::ops::Add`), `Output` (from the trait `std::ops::Sub`) must be specified
2427
--> $DIR/issue-22560.rs:3:13
2528
|
2629
LL | type Test = Add +
2730
| _____________^
31+
| |_____________|
32+
| |
2833
LL | |
2934
LL | |
3035
LL | | Sub;
31-
| |_______________^ associated type `Output` must be specified
36+
| | ^
37+
| |_______________|
38+
| |_______________associated type `Output` must be specified
39+
| associated type `Output` must be specified
3240

3341
error: aborting due to 4 previous errors
3442

src/test/ui/issues/issue-32963.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0225]: only auto traits can be used as additional traits in a trait objec
22
--> $DIR/issue-32963.rs:8:25
33
|
44
LL | size_of_copy::<Misc+Copy>();
5-
| ^^^^ non-auto additional trait
5+
| ---- ^^^^ additional non-auto trait
6+
| |
7+
| first non-auto trait
68

79
error[E0277]: the trait bound `dyn Misc: std::marker::Copy` is not satisfied
810
--> $DIR/issue-32963.rs:8:5

src/test/ui/maybe-bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
trait Tr: ?Sized {} //~ ERROR `?Trait` is not permitted in supertraits
22

3-
type A1 = Tr + (?Sized); //~ ERROR `?Trait` is not permitted in trait object types
4-
type A2 = for<'a> Tr + (?Sized); //~ ERROR `?Trait` is not permitted in trait object types
3+
type A1 = Tr + (?Sized);
4+
type A2 = for<'a> Tr + (?Sized);
55

66
fn main() {}

src/test/ui/maybe-bounds.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,5 @@ LL | trait Tr: ?Sized {}
66
|
77
= note: traits are `?Sized` by default
88

9-
error: `?Trait` is not permitted in trait object types
10-
--> $DIR/maybe-bounds.rs:3:16
11-
|
12-
LL | type A1 = Tr + (?Sized);
13-
| ^^^^^^^^
14-
15-
error: `?Trait` is not permitted in trait object types
16-
--> $DIR/maybe-bounds.rs:4:24
17-
|
18-
LL | type A2 = for<'a> Tr + (?Sized);
19-
| ^^^^^^^^
20-
21-
error: aborting due to 3 previous errors
9+
error: aborting due to previous error
2210

src/test/ui/parser/trait-object-trait-parens.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ fn f<T: (Copy) + (?Sized) + (for<'a> Trait<'a>)>() {}
44

55
fn main() {
66
let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
7-
//~^ ERROR `?Trait` is not permitted in trait object types
87
let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>;
98
let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
10-
//~^ ERROR `?Trait` is not permitted in trait object types
11-
//~| ERROR use of undeclared lifetime name `'a`
9+
//~^ ERROR use of undeclared lifetime name `'a`
1210
}
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
error: `?Trait` is not permitted in trait object types
2-
--> $DIR/trait-object-trait-parens.rs:6:25
3-
|
4-
LL | let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>;
5-
| ^^^^^^^^
6-
7-
error: `?Trait` is not permitted in trait object types
8-
--> $DIR/trait-object-trait-parens.rs:9:47
9-
|
10-
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
11-
| ^^^^^^^^
12-
131
error[E0261]: use of undeclared lifetime name `'a`
14-
--> $DIR/trait-object-trait-parens.rs:9:31
2+
--> $DIR/trait-object-trait-parens.rs:8:31
153
|
164
LL | let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>;
175
| ^^ undeclared lifetime
186

19-
error: aborting due to 3 previous errors
7+
error: aborting due to previous error
208

219
For more information about this error, try `rustc --explain E0261`.

src/test/ui/traits/trait-alias-object.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/test/run-pass/traits/trait-alias-bounds.rs renamed to src/test/ui/traits/trait-alias/trait-alias-bounds.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// run-pass
2+
13
#![feature(trait_alias)]
24

35
use std::marker::PhantomData;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Test that `dyn ... + ?Sized + ...` resulting from the expansion of trait aliases is okay.
2+
3+
#![feature(trait_alias)]
4+
5+
trait S = ?Sized;
6+
7+
// Nest a couple of levels deep:
8+
trait _0 = S;
9+
trait _1 = _0;
10+
11+
// Straight list expansion:
12+
type _T0 = dyn _1;
13+
//~^ ERROR at least one non-builtin trait is required for an object type [E0224]
14+
15+
// In second position:
16+
type _T1 = dyn Copy + _1;
17+
18+
// ... and with an auto trait:
19+
type _T2 = dyn Copy + Send + _1;
20+
21+
// Twice:
22+
trait _2 = _1 + _1;
23+
24+
type _T3 = dyn _2;
25+
//~^ ERROR at least one non-builtin trait is required for an object type [E0224]
26+
27+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0224]: at least one non-builtin trait is required for an object type
2+
--> $DIR/trait-alias-maybe-bound.rs:12:12
3+
|
4+
LL | type _T0 = dyn _1;
5+
| ^^^^^^
6+
7+
error[E0224]: at least one non-builtin trait is required for an object type
8+
--> $DIR/trait-alias-maybe-bound.rs:24:12
9+
|
10+
LL | type _T3 = dyn _2;
11+
| ^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// The purpose of this test is to demonstrate that duplicating object safe traits
2+
// that are not auto traits is rejected with trait aliases even though one could
3+
// reasonably accept this.
4+
5+
#![feature(trait_alias)]
6+
7+
use std::marker::Unpin;
8+
9+
// Some arbitray object-safe trait:
10+
trait Obj {}
11+
12+
// Nest a few levels deep:
13+
trait _0 = Obj;
14+
trait _1 = _0;
15+
16+
type _T00 = dyn _0 + _0;
17+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
18+
19+
type _T01 = dyn _1 + _0;
20+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
21+
22+
type _T02 = dyn _1 + _1;
23+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
24+
25+
type _T03 = dyn Obj + _1;
26+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
27+
28+
type _T04 = dyn _1 + Obj;
29+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
30+
31+
// Nest some more and in weird ways:
32+
33+
trait _2 = _0 + _1;
34+
trait _3 = Obj;
35+
trait _4 = _3;
36+
37+
type _T10 = dyn _2 + _3;
38+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
39+
40+
type _T11 = dyn _3 + _2;
41+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
42+
43+
type _T12 = dyn Obj + _2;
44+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
45+
46+
type _T13 = dyn _2 + Obj;
47+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
48+
49+
type _T14 = dyn _1 + _3;
50+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
51+
52+
type _T15 = dyn _3 + _1;
53+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
54+
55+
type _T16 = dyn _1 + _4;
56+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
57+
58+
type _T17 = dyn _4 + _1;
59+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
60+
61+
// Include auto traits:
62+
63+
trait _5 = Obj + Send;
64+
65+
type _T20 = dyn _5 + _5;
66+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
67+
68+
type _T21 = dyn Obj + _5;
69+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
70+
71+
type _T22 = dyn _5 + Obj;
72+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
73+
74+
type _T23 = dyn _5 + Send + Sync + Obj;
75+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
76+
77+
// Also nest:
78+
79+
trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
80+
81+
type _T30 = dyn _6;
82+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
83+
84+
type _T31 = dyn _6 + Send;
85+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
86+
87+
type _T32 = dyn Send + _6;
88+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
89+
90+
// Nest some more:
91+
92+
trait _7 = _5 + Sync;
93+
trait _8 = Unpin + _7;
94+
95+
type _T40 = dyn _8 + Obj;
96+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
97+
98+
type _T41 = dyn Obj + _8;
99+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
100+
101+
type _T42 = dyn _8 + _4;
102+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
103+
104+
type _T43 = dyn _4 + _8;
105+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
106+
107+
type _T44 = dyn _4 + Send + Sync + _8;
108+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
109+
110+
// Take higher ranked types into account.
111+
112+
// Note that `'a` and `'b` are intentionally different to make sure we consider
113+
// them semantically the same.
114+
trait ObjL<'l> {}
115+
trait _9 = for<'a> ObjL<'a>;
116+
trait _10 = for<'b> ObjL<'b>;
117+
type _T50 = _9 + _10;
118+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
119+
120+
trait ObjT<T> {}
121+
trait _11 = ObjT<for<'a> fn(&'a u8)>;
122+
trait _12 = ObjT<for<'b> fn(&'b u8)>;
123+
type _T60 = _11 + _12;
124+
//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
125+
126+
fn main() {}

0 commit comments

Comments
 (0)