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
error: the trait `Foo` cannot be made into an object
2
-
--> $DIR/object-safety-err-where-bounds.rs:9:8
1
+
error[E0038]: the trait `Foo` cannot be made into an object
2
+
--> $DIR/object-safety-err-where-bounds.rs:15:16
3
3
|
4
-
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
5
-
| ^^^^
4
+
LL | fn use_dyn(v: &dyn Foo) {
5
+
| ^^^^^^^ `Foo` cannot be made into an object
6
6
|
7
-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8
-
= note: for more information, see issue #51443 <https://github.com/rust-lang/rust/issues/51443>
9
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>
10
-
--> $DIR/object-safety-err-where-bounds.rs:9:8
8
+
--> $DIR/object-safety-err-where-bounds.rs:8:8
11
9
|
12
10
LL | trait Foo {
13
11
| --- this trait cannot be made into an object...
14
12
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
15
13
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
16
14
= help: consider moving `test` to another trait
17
-
note: the lint level is defined here
18
-
--> $DIR/object-safety-err-where-bounds.rs:3:9
15
+
= help: only type `()` implements the trait, consider using it directly instead
16
+
17
+
error[E0038]: the trait `Foo` cannot be made into an object
18
+
--> $DIR/object-safety-err-where-bounds.rs:17:5
19
+
|
20
+
LL | v.test();
21
+
| ^^^^^^^^ `Foo` cannot be made into an object
22
+
|
23
+
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>
24
+
--> $DIR/object-safety-err-where-bounds.rs:8:8
19
25
|
20
-
LL | #![deny(where_clauses_object_safety)]
21
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
+
LL | trait Foo {
27
+
| --- this trait cannot be made into an object...
28
+
LL | fn test(&self) where [u8; bar::<Self>()]: Sized;
29
+
| ^^^^ ...because method `test` references the `Self` type in its `where` clause
30
+
= help: consider moving `test` to another trait
31
+
= help: only type `()` implements the trait, consider using it directly instead
22
32
23
-
error: aborting due to 1 previous error
33
+
error: aborting due to 2 previous errors
24
34
35
+
For more information about this error, try `rustc --explain E0038`.
error: the trait `X` cannot be made into an object
2
-
--> $DIR/issue-50781.rs:6:8
1
+
error[E0038]: the trait `X` cannot be made into an object
2
+
--> $DIR/issue-50781.rs:11:16
3
3
|
4
+
LL | impl Trait for dyn X {}
5
+
| ^^^^^ `X` 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/issue-50781.rs:4:8
9
+
|
10
+
LL | trait X {
11
+
| - this trait cannot be made into an object...
4
12
LL | fn foo(&self) where Self: Trait;
5
-
| ^^^
13
+
| ^^^ ...because method `foo` references the `Self` type in its `where` clause
14
+
= help: consider moving `foo` to another trait
15
+
= help: only type `()` implements the trait, consider using it directly instead
16
+
17
+
error[E0038]: the trait `X` cannot be made into an object
18
+
--> $DIR/issue-50781.rs:16:23
19
+
|
20
+
LL | <dyn X as X>::foo(&());
21
+
| ^^^ `X` cannot be made into an object
6
22
|
7
-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8
-
= note: for more information, see issue #51443 <https://github.com/rust-lang/rust/issues/51443>
9
23
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>
10
-
--> $DIR/issue-50781.rs:6:8
24
+
--> $DIR/issue-50781.rs:4:8
11
25
|
12
26
LL | trait X {
13
27
| - this trait cannot be made into an object...
14
28
LL | fn foo(&self) where Self: Trait;
15
29
| ^^^ ...because method `foo` references the `Self` type in its `where` clause
16
30
= help: consider moving `foo` to another trait
17
-
note: the lint level is defined here
18
-
--> $DIR/issue-50781.rs:1:9
31
+
= help: only type `()` implements the trait, consider using it directly instead
32
+
= note: required for the cast from `&()` to `&dyn X`
33
+
34
+
error[E0038]: the trait `X` cannot be made into an object
35
+
--> $DIR/issue-50781.rs:16:6
36
+
|
37
+
LL | <dyn X as X>::foo(&());
38
+
| ^^^^^ `X` cannot be made into an object
19
39
|
20
-
LL | #![deny(where_clauses_object_safety)]
21
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
40
+
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>
41
+
--> $DIR/issue-50781.rs:4:8
42
+
|
43
+
LL | trait X {
44
+
| - this trait cannot be made into an object...
45
+
LL | fn foo(&self) where Self: Trait;
46
+
| ^^^ ...because method `foo` references the `Self` type in its `where` clause
47
+
= help: consider moving `foo` to another trait
48
+
= help: only type `()` implements the trait, consider using it directly instead
22
49
23
-
error: aborting due to 1 previous error
50
+
error: aborting due to 3 previous errors
24
51
52
+
For more information about this error, try `rustc --explain E0038`.
0 commit comments