You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #100247 - cjgillot:verify-dyn-trait-alias-defaults, r=lcnr
Generalize trait object generic param check to aliases.
The current algorithm only checks that `Self` does not appear in defaults for traits. This is not sufficient for trait aliases.
This PR moves the check to trait object elaboration, which sees through trait aliases.
Fixes#82927.
Fixes#84789.
Copy file name to clipboardexpand all lines: src/test/ui/associated-types/issue-22560.stderr
+23-23
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,3 @@
1
-
error[E0393]: the type parameter `Rhs` must be explicitly specified
2
-
--> $DIR/issue-22560.rs:9:23
3
-
|
4
-
LL | trait Sub<Rhs=Self> {
5
-
| ------------------- type parameter `Rhs` must be specified for this
6
-
...
7
-
LL | type Test = dyn Add + Sub;
8
-
| ^^^ help: set the type parameter to the desired type: `Sub<Rhs>`
9
-
|
10
-
= note: because of the default `Self` reference, type parameters must be specified on object types
11
-
12
-
error[E0393]: the type parameter `Rhs` must be explicitly specified
13
-
--> $DIR/issue-22560.rs:9:17
14
-
|
15
-
LL | trait Add<Rhs=Self> {
16
-
| ------------------- type parameter `Rhs` must be specified for this
17
-
...
18
-
LL | type Test = dyn Add + Sub;
19
-
| ^^^ help: set the type parameter to the desired type: `Add<Rhs>`
20
-
|
21
-
= note: because of the default `Self` reference, type parameters must be specified on object types
22
-
23
1
error[E0225]: only auto traits can be used as additional traits in a trait object
24
2
--> $DIR/issue-22560.rs:9:23
25
3
|
@@ -28,7 +6,7 @@ LL | type Test = dyn Add + Sub;
28
6
| |
29
7
| first non-auto trait
30
8
|
31
-
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<[type error]> + Sub<[type error]> {}`
9
+
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add+ Sub {}`
32
10
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
33
11
34
12
error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified
@@ -50,6 +28,28 @@ help: specify the associated types
50
28
LL | type Test = dyn Add<Output = Type> + Sub<Output = Type>;
51
29
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
52
30
31
+
error[E0393]: the type parameter `Rhs` must be explicitly specified
32
+
--> $DIR/issue-22560.rs:9:17
33
+
|
34
+
LL | trait Add<Rhs=Self> {
35
+
| ------------------- type parameter `Rhs` must be specified for this
36
+
...
37
+
LL | type Test = dyn Add + Sub;
38
+
| ^^^ help: set the type parameter to the desired type: `Add<Rhs>`
39
+
|
40
+
= note: because of the default `Self` reference, type parameters must be specified on object types
41
+
42
+
error[E0393]: the type parameter `Rhs` must be explicitly specified
43
+
--> $DIR/issue-22560.rs:9:23
44
+
|
45
+
LL | trait Sub<Rhs=Self> {
46
+
| ------------------- type parameter `Rhs` must be specified for this
47
+
...
48
+
LL | type Test = dyn Add + Sub;
49
+
| ^^^ help: set the type parameter to the desired type: `Sub<Rhs>`
50
+
|
51
+
= note: because of the default `Self` reference, type parameters must be specified on object types
52
+
53
53
error: aborting due to 4 previous errors
54
54
55
55
Some errors have detailed explanations: E0191, E0225, E0393.
0 commit comments