Files
rust/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr
Esteban Küber f0845adb0c Show diff suggestion format on verbose replacement
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |
```
2025-02-10 20:21:39 +00:00

70 lines
2.3 KiB
Plaintext

error: associated item referring to unboxed trait object for its own trait
--> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13
|
LL | trait A: Sized {
| - in this trait
LL | fn f(a: A) -> A;
| ^ ^
|
help: you might have meant to use `Self` to refer to the implementing type
|
LL - fn f(a: A) -> A;
LL + fn f(a: Self) -> Self;
|
error[E0038]: the trait `A` is not dyn compatible
--> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13
|
LL | fn f(a: A) -> A;
| ^ `A` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/dyn-incompatible-trait-should-use-self.rs:2:10
|
LL | trait A: Sized {
| - ^^^^^ ...because it requires `Self: Sized`
| |
| this trait is not dyn compatible...
error: associated item referring to unboxed trait object for its own trait
--> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13
|
LL | trait B {
| - in this trait
LL | fn f(a: B) -> B;
| ^ ^
|
help: you might have meant to use `Self` to refer to the implementing type
|
LL - fn f(a: B) -> B;
LL + fn f(a: Self) -> Self;
|
error[E0038]: the trait `B` is not dyn compatible
--> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13
|
LL | fn f(a: B) -> B;
| ^ `B` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/dyn-incompatible-trait-should-use-self.rs:8:8
|
LL | trait B {
| - this trait is not dyn compatible...
LL | fn f(a: B) -> B;
| ^ ...because associated function `f` has no `self` parameter
help: consider turning `f` into a method by giving it a `&self` argument
|
LL | fn f(&self, a: B) -> B;
| ++++++
help: alternatively, consider constraining `f` so it does not apply to trait objects
|
LL | fn f(a: B) -> B where Self: Sized;
| +++++++++++++++++
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0038`.