2020-01-20 01:27:37 +00:00
error: associated item referring to unboxed trait object for its own trait
--> $DIR/object-unsafe-trait-should-use-self.rs:3:13
|
LL | trait A: Sized {
| - in this trait
LL | fn f(a: A) -> A;
| ^ ^
|
2020-01-25 22:28:23 +00:00
help: you might have meant to use `Self` to refer to the implementing type
2020-01-20 01:27:37 +00:00
|
LL | fn f(a: Self) -> Self;
2021-06-22 02:07:19 +00:00
| ~~~~ ~~~~
2020-01-20 01:27:37 +00:00
error[E0038]: the trait `A` cannot be made into an object
--> $DIR/object-unsafe-trait-should-use-self.rs:3:13
|
2020-10-16 00:23:45 +00:00
LL | fn f(a: A) -> A;
2020-10-20 00:57:18 +00:00
| ^ `A` cannot be made into an object
2020-10-16 00:23:45 +00:00
|
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>
--> $DIR/object-unsafe-trait-should-use-self.rs:2:10
|
2020-01-20 01:27:37 +00:00
LL | trait A: Sized {
2020-10-16 00:23:45 +00:00
| - ^^^^^ ...because it requires `Self: Sized`
2020-02-01 00:47:00 +00:00
| |
| this trait cannot be made into an object...
2020-01-20 01:27:37 +00:00
error: associated item referring to unboxed trait object for its own trait
--> $DIR/object-unsafe-trait-should-use-self.rs:8:13
|
LL | trait B {
| - in this trait
LL | fn f(a: B) -> B;
| ^ ^
|
2020-01-25 22:28:23 +00:00
help: you might have meant to use `Self` to refer to the implementing type
2020-01-20 01:27:37 +00:00
|
LL | fn f(a: Self) -> Self;
2021-06-22 02:07:19 +00:00
| ~~~~ ~~~~
2020-01-20 01:27:37 +00:00
error[E0038]: the trait `B` cannot be made into an object
--> $DIR/object-unsafe-trait-should-use-self.rs:8:13
|
2020-10-16 00:23:45 +00:00
LL | fn f(a: B) -> B;
2020-10-20 00:57:18 +00:00
| ^ `B` cannot be made into an object
2020-10-16 00:23:45 +00:00
|
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>
--> $DIR/object-unsafe-trait-should-use-self.rs:8:8
|
2020-02-01 00:47:00 +00:00
LL | trait B {
| - this trait cannot be made into an object...
2020-01-20 01:27:37 +00:00
LL | fn f(a: B) -> B;
2020-10-16 00:23:45 +00:00
| ^ ...because associated function `f` has no `self` parameter
help: consider turning `f` into a method by giving it a `&self` argument
2020-02-01 00:47:00 +00:00
|
2020-10-16 00:23:45 +00:00
LL | fn f(&self, a: B) -> B;
2021-06-22 02:07:19 +00:00
| ++++++
2020-10-16 00:23:45 +00:00
help: alternatively, consider constraining `f` so it does not apply to trait objects
2020-02-01 02:48:35 +00:00
|
LL | fn f(a: B) -> B where Self: Sized;
2021-06-22 02:07:19 +00:00
| +++++++++++++++++
2020-01-20 01:27:37 +00:00
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0038`.