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
Start performing a WF-check on `type`s to verify that they will be able
to be constructed. Do *not* perform a `Sized` check, as
`type T = dyn Trait;` should be allowed. Do *not* WF-check `type`s with
type parameters because we currently lint *against*
`type T<X: Trait> = K<X>;` because we do not propagate `X: Trait`,
which means that we currently allow `type T<X> = <X as Trait>::Foo;`,
which would be rejected if we WF-checked it because it would need to be
written as `type T<X: Trait> = <X as Trait>::Foo;` to be correct.
Instead, we simply don't check it at definition and only do so at use
like we do currently. In the future, the alternatives would be to
either automatically backpropagate the `X: Trait` obligation when
WF-checking the `type` or (my preferred solution) properly propagate
the explicit `X: Trait` obligation to the uses, which would likely be a
breaking change.
Fixesrust-lang#60980 by using a more appropriate span for the error.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object
54
+
|
55
+
= note: the trait cannot be made into an object because it requires `Self: Sized`
56
+
= note: for a trait to be "object safe" 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>
57
+
58
+
error[E0038]: the trait `Copy` cannot be made into an object
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object
63
+
|
64
+
= note: the trait cannot be made into an object because it requires `Self: Sized`
65
+
= note: for a trait to be "object safe" 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>
66
+
67
+
error[E0038]: the trait `Copy` cannot be made into an object
68
+
--> $DIR/cfg-generic-params.rs:31:15
69
+
|
70
+
LL | type PolyNo = dyn for<#[cfg_attr(no, unknown)] 'a> Copy; // OK
71
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object
72
+
|
73
+
= note: the trait cannot be made into an object because it requires `Self: Sized`
74
+
= note: for a trait to be "object safe" 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>
75
+
76
+
error[E0038]: the trait `Copy` cannot be made into an object
77
+
--> $DIR/cfg-generic-params.rs:33:16
78
+
|
79
+
LL | type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy;
80
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object
81
+
|
82
+
= note: the trait cannot be made into an object because it requires `Self: Sized`
83
+
= note: for a trait to be "object safe" 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>
84
+
85
+
error: aborting due to 12 previous errors
50
86
87
+
For more information about this error, try `rustc --explain E0038`.
Copy file name to clipboardExpand all lines: src/test/ui/resolve/issue-3907-2.stderr
+13-1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,15 @@
1
+
error[E0038]: the trait `issue_3907::Foo` cannot be made into an object
2
+
--> $DIR/issue-3907-2.rs:5:12
3
+
|
4
+
LL | type Foo = dyn issue_3907::Foo + 'static;
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `issue_3907::Foo` cannot be made into an object
6
+
|
7
+
note: for a trait to be "object safe" 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>
8
+
--> $DIR/auxiliary/issue-3907.rs:2:8
9
+
|
10
+
LL | fn bar();
11
+
| ^^^ the trait cannot be made into an object because associated function `bar` has no `self` parameter
12
+
1
13
error[E0038]: the trait `issue_3907::Foo` cannot be made into an object
2
14
--> $DIR/issue-3907-2.rs:11:12
3
15
|
@@ -10,6 +22,6 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
10
22
LL | fn bar();
11
23
| ^^^ the trait cannot be made into an object because associated function `bar` has no `self` parameter
12
24
13
-
error: aborting due to previous error
25
+
error: aborting due to 2 previous errors
14
26
15
27
For more information about this error, try `rustc --explain E0038`.
0 commit comments