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 #133394 - compiler-errors:dyn-more-errors, r=lcnr
Bail on more errors in dyn ty lowering
If we have more than one principal trait, or if we have a principal trait with errors in it, then bail with `TyKind::Error` rather than attempting lowering. Lowering a dyn trait with more than one principal just arbitrarily chooses the first one and drops the subsequent ones, and lowering a dyn trait path with errors in it is just kinda useless.
This suppresses unnecessary errors which I think is net-good, but also is important to make sure that we don't end up leaking `{type error}` in #133388 error messaging :)
r? types
Copy file name to clipboardExpand all lines: tests/ui/associated-types/issue-22560.stderr
+2-52
Original file line number
Diff line number
Diff line change
@@ -9,56 +9,6 @@ LL | type Test = dyn Add + Sub;
9
9
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub {}`
10
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>
11
11
12
-
error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified
13
-
--> $DIR/issue-22560.rs:9:17
14
-
|
15
-
LL | type Output;
16
-
| ----------- `Output` defined here
17
-
...
18
-
LL | type Output;
19
-
| ----------- `Output` defined here
20
-
...
21
-
LL | type Test = dyn Add + Sub;
22
-
| ^^^ ^^^ associated type `Output` must be specified
23
-
| |
24
-
| associated type `Output` must be specified
25
-
|
26
-
help: specify the associated types
27
-
|
28
-
LL | type Test = dyn Add<Output = Type> + Sub<Output = Type>;
29
-
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
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
-
| ^^^
39
-
|
40
-
= note: because of the default `Self` reference, type parameters must be specified on object types
41
-
help: set the type parameter to the desired type
42
-
|
43
-
LL | type Test = dyn Add<Rhs> + Sub;
44
-
| +++++
45
-
46
-
error[E0393]: the type parameter `Rhs` must be explicitly specified
47
-
--> $DIR/issue-22560.rs:9:23
48
-
|
49
-
LL | trait Sub<Rhs=Self> {
50
-
| ------------------- type parameter `Rhs` must be specified for this
51
-
...
52
-
LL | type Test = dyn Add + Sub;
53
-
| ^^^
54
-
|
55
-
= note: because of the default `Self` reference, type parameters must be specified on object types
56
-
help: set the type parameter to the desired type
57
-
|
58
-
LL | type Test = dyn Add + Sub<Rhs>;
59
-
| +++++
60
-
61
-
error: aborting due to 4 previous errors
12
+
error: aborting due to 1 previous error
62
13
63
-
Some errors have detailed explanations: E0191, E0225, E0393.
64
-
For more information about an error, try `rustc --explain E0191`.
14
+
For more information about this error, try `rustc --explain E0225`.
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + X<Rhs> + Y<Rhs> {}`
10
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>
11
11
12
-
error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + X<Rhs> + Z<Rhs> {}`
39
21
= 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>
40
22
41
-
error[E0191]: the value of the associated types `A` and `B` in `Z`, `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + Y<Rhs> {}`
75
32
= 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>
76
33
77
-
error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Sub` must be specified
= help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + Fine<Rhs> {}`
103
43
= 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>
104
44
105
-
error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
20
20
21
-
error[E0038]: the trait `Trait` cannot be made into an object
22
-
--> $DIR/not_wf_param_in_rpitit.rs:3:22
23
-
|
24
-
LL | trait Trait<const N: dyn Trait = bar> {
25
-
| ^^^^^^^^^ `Trait` cannot be made into an object
26
-
|
27
-
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
28
-
--> $DIR/not_wf_param_in_rpitit.rs:9:14
29
-
|
30
-
LL | trait Trait<const N: dyn Trait = bar> {
31
-
| ----- this trait cannot be made into an object...
32
-
...
33
-
LL | async fn a() {}
34
-
| ^ ...because associated function `a` has no `self` parameter
35
-
help: consider turning `a` into a method by giving it a `&self` argument
36
-
|
37
-
LL | async fn a(&self) {}
38
-
| +++++
39
-
help: alternatively, consider constraining `a` so it does not apply to trait objects
40
-
|
41
-
LL | async fn a() where Self: Sized {}
42
-
| +++++++++++++++++
43
-
44
-
error[E0038]: the trait `Trait` cannot be made into an object
45
-
--> $DIR/not_wf_param_in_rpitit.rs:3:13
46
-
|
47
-
LL | trait Trait<const N: dyn Trait = bar> {
48
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
49
-
|
50
-
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
51
-
--> $DIR/not_wf_param_in_rpitit.rs:9:14
52
-
|
53
-
LL | trait Trait<const N: dyn Trait = bar> {
54
-
| ----- this trait cannot be made into an object...
55
-
...
56
-
LL | async fn a() {}
57
-
| ^ ...because associated function `a` has no `self` parameter
58
-
help: consider turning `a` into a method by giving it a `&self` argument
59
-
|
60
-
LL | async fn a(&self) {}
61
-
| +++++
62
-
help: alternatively, consider constraining `a` so it does not apply to trait objects
63
-
|
64
-
LL | async fn a() where Self: Sized {}
65
-
| +++++++++++++++++
66
-
67
-
error[E0038]: the trait `Trait` cannot be made into an object
68
-
--> $DIR/not_wf_param_in_rpitit.rs:3:13
69
-
|
70
-
LL | trait Trait<const N: dyn Trait = bar> {
71
-
| ^^^^^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
72
-
|
73
-
note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
74
-
--> $DIR/not_wf_param_in_rpitit.rs:9:14
75
-
|
76
-
LL | trait Trait<const N: dyn Trait = bar> {
77
-
| ----- this trait cannot be made into an object...
78
-
...
79
-
LL | async fn a() {}
80
-
| ^ ...because associated function `a` has no `self` parameter
81
-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
82
-
help: consider turning `a` into a method by giving it a `&self` argument
83
-
|
84
-
LL | async fn a(&self) {}
85
-
| +++++
86
-
help: alternatively, consider constraining `a` so it does not apply to trait objects
87
-
|
88
-
LL | async fn a() where Self: Sized {}
89
-
| +++++++++++++++++
90
-
91
-
error: aborting due to 5 previous errors
21
+
error: aborting due to 2 previous errors
92
22
93
-
Some errors have detailed explanations: E0038, E0391, E0425.
94
-
For more information about an error, try `rustc --explain E0038`.
23
+
Some errors have detailed explanations: E0391, E0425.
24
+
For more information about an error, try `rustc --explain E0391`.
0 commit comments