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
Copy file name to clipboardExpand all lines: src/test/ui/associated-consts/associated-const-in-trait.stderr
+7-5
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,17 @@
1
1
error[E0038]: the trait `Trait` cannot be made into an object
2
2
--> $DIR/associated-const-in-trait.rs:9:6
3
3
|
4
-
LL | trait Trait {
5
-
| ----- this trait cannot be made into an object...
6
-
LL | const N: usize;
7
-
| - ...because it contains this associated `const`
8
-
...
9
4
LL | impl dyn Trait {
10
5
| ^^^^^^^^^ the trait `Trait` cannot be made into an object
11
6
|
12
7
= help: consider moving `N` to another trait
8
+
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>
9
+
--> $DIR/associated-const-in-trait.rs:6:11
10
+
|
11
+
LL | trait Trait {
12
+
| ----- this trait cannot be made into an object...
13
+
LL | const N: usize;
14
+
| ^ ...because it contains this associated `const`
Copy file name to clipboardExpand all lines: src/test/ui/associated-item/issue-48027.stderr
+7-5
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,17 @@
1
1
error[E0038]: the trait `Bar` cannot be made into an object
2
2
--> $DIR/issue-48027.rs:6:6
3
3
|
4
-
LL | trait Bar {
5
-
| --- this trait cannot be made into an object...
6
-
LL | const X: usize;
7
-
| - ...because it contains this associated `const`
8
-
...
9
4
LL | impl dyn Bar {}
10
5
| ^^^^^^^ the trait `Bar` cannot be made into an object
11
6
|
12
7
= help: consider moving `X` to another trait
8
+
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>
9
+
--> $DIR/issue-48027.rs:2:11
10
+
|
11
+
LL | trait Bar {
12
+
| --- this trait cannot be made into an object...
13
+
LL | const X: usize;
14
+
| ^ ...because it contains this associated `const`
| ------------- ---- ...because method `eq` references the `Self` type in this parameter
6
-
| |
7
-
| this trait cannot be made into an object...
8
4
LL | impl NotObjectSafe for dyn NotObjectSafe { }
9
5
| ^^^^^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
10
6
|
11
7
= help: consider moving `eq` to another trait
8
+
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>
Copy file name to clipboardExpand all lines: src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr
+1
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ LL | let _: &Copy + 'static;
17
17
| ^^^^^ the trait `Copy` cannot be made into an object
18
18
|
19
19
= note: the trait cannot be made into an object because it requires `Self: Sized`
20
+
= 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>
error[E0038]: the trait `SomeTrait` cannot be made into an object
8
8
--> $DIR/E0033-teach.rs:8:20
9
9
|
10
+
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
11
+
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
12
+
|
13
+
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>
14
+
--> $DIR/E0033-teach.rs:4:8
15
+
|
10
16
LL | trait SomeTrait {
11
17
| --------- this trait cannot be made into an object...
12
18
LL | fn foo();
13
-
| --- ...because associated function `foo` has no `self` parameter
14
-
...
15
-
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
16
-
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
19
+
| ^^^ ...because associated function `foo` has no `self` parameter
20
+
help: consider turning `foo` into a method by giving it a `&self` argument
17
21
|
18
-
help: consider turning `foo` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
22
+
LL | fn foo(&self);
23
+
| ^^^^^
24
+
help: alternatively, consider constraining `foo` so it does not apply to trait objects
0 commit comments