2024-11-20 14:19:36 -08:00
error[E0038]: the trait `Trait` is not dyn compatible
2024-10-09 23:31:01 +02:00
--> $DIR/dyn-incompatible-trait-should-use-where-sized.rs:9:12
2020-01-31 19:04:58 -08:00
|
2020-10-15 17:23:45 -07:00
LL | fn bar(x: &dyn Trait) {}
2024-11-20 14:19:36 -08:00
| ^^^^^^^^^ `Trait` is not dyn compatible
2020-10-15 17:23:45 -07:00
|
2024-11-20 14:19:36 -08:00
note: for a trait to be dyn compatible it needs to allow building a vtable
2025-01-22 05:14:07 +01:00
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
2024-10-09 23:31:01 +02:00
--> $DIR/dyn-incompatible-trait-should-use-where-sized.rs:5:8
2020-10-15 17:23:45 -07:00
|
2020-01-31 19:04:58 -08:00
LL | trait Trait {
2024-11-20 14:19:36 -08:00
| ----- this trait is not dyn compatible...
2020-01-31 19:04:58 -08:00
LL | fn foo() where Self: Other, { }
2020-10-15 17:23:45 -07:00
| ^^^ ...because associated function `foo` has no `self` parameter
2020-01-31 19:04:58 -08:00
LL | fn bar(self: ()) {}
2020-10-15 17:23:45 -07:00
| ^^ ...because method `bar`'s `self` parameter cannot be dispatched on
help: consider turning `foo` into a method by giving it a `&self` argument
2020-01-31 19:04:58 -08:00
|
2020-10-15 17:23:45 -07:00
LL | fn foo(&self) where Self: Other, { }
2021-06-21 19:07:19 -07:00
| +++++
2020-10-15 17:23:45 -07:00
help: alternatively, consider constraining `foo` so it does not apply to trait objects
2020-01-31 19:04:58 -08:00
|
2025-02-13 02:54:07 +00:00
LL | fn foo() where Self: Other, Self: Sized { }
2025-02-13 03:21:25 +00:00
| +++++++++++
2020-01-31 19:04:58 -08:00
help: consider changing method `bar`'s `self` parameter to be `&self`
|
2024-07-09 22:30:26 +00:00
LL - fn bar(self: ()) {}
LL + fn bar(self: &Self) {}
|
2020-01-31 19:04:58 -08:00
2024-04-25 03:11:19 +02:00
error[E0307]: invalid `self` parameter type: `()`
2024-10-09 23:31:01 +02:00
--> $DIR/dyn-incompatible-trait-should-use-where-sized.rs:6:18
2022-06-12 00:47:21 +02:00
|
LL | fn bar(self: ()) {}
| ^^
|
2024-12-13 15:40:37 +00:00
= note: type of `self` must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
2022-06-12 00:47:21 +02:00
2020-01-31 19:04:58 -08:00
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0038, E0307.
For more information about an error, try `rustc --explain E0038`.