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: tests/ui/error-codes/E0120.stderr
+25-2
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,29 @@ error[E0120]: the `Drop` trait may only be implemented for local structs, enums,
4
4
LL | impl Drop for dyn MyTrait {
5
5
| ^^^^^^^^^^^ must be a struct, enum, or union in the current crate
6
6
7
-
error: aborting due to 1 previous error
7
+
error[E0038]: the trait `MyTrait` cannot be made into an object
8
+
--> $DIR/E0120.rs:5:18
9
+
|
10
+
LL | fn drop(&mut self) {}
11
+
| ^^^^ `MyTrait` 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/E0120.rs:1:20
15
+
|
16
+
LL | trait MyTrait { fn foo() {} }
17
+
| ------- ^^^ ...because associated function `foo` has no `self` parameter
18
+
| |
19
+
| this trait cannot be made into an object...
20
+
help: consider turning `foo` into a method by giving it a `&self` argument
21
+
|
22
+
LL | trait MyTrait { fn foo(&self) {} }
23
+
| +++++
24
+
help: alternatively, consider constraining `foo` so it does not apply to trait objects
0 commit comments