]>
Commit | Line | Data |
---|---|---|
dfeec247 | 1 | error[E0038]: the trait `NotObjectSafe` cannot be made into an object |
74b04a01 | 2 | --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:21:13 |
dfeec247 | 3 | | |
29967ef6 XL |
4 | LL | fn car() -> dyn NotObjectSafe { |
5 | | ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | |
6 | | | |
7 | 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> | |
8 | --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8 | |
9 | | | |
74b04a01 XL |
10 | LL | trait NotObjectSafe { |
11 | | ------------- this trait cannot be made into an object... | |
dfeec247 | 12 | LL | fn foo() -> Self; |
29967ef6 XL |
13 | | ^^^ ...because associated function `foo` has no `self` parameter |
14 | help: consider turning `foo` into a method by giving it a `&self` argument | |
74b04a01 | 15 | | |
29967ef6 | 16 | LL | fn foo(&self) -> Self; |
94222f64 | 17 | | +++++ |
29967ef6 | 18 | help: alternatively, consider constraining `foo` so it does not apply to trait objects |
74b04a01 XL |
19 | | |
20 | LL | fn foo() -> Self where Self: Sized; | |
94222f64 | 21 | | +++++++++++++++++ |
dfeec247 XL |
22 | |
23 | error[E0038]: the trait `NotObjectSafe` cannot be made into an object | |
74b04a01 | 24 | --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:28:13 |
dfeec247 | 25 | | |
29967ef6 XL |
26 | LL | fn cat() -> Box<dyn NotObjectSafe> { |
27 | | ^^^^^^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object | |
28 | | | |
29 | 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> | |
30 | --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8 | |
31 | | | |
74b04a01 XL |
32 | LL | trait NotObjectSafe { |
33 | | ------------- this trait cannot be made into an object... | |
dfeec247 | 34 | LL | fn foo() -> Self; |
29967ef6 XL |
35 | | ^^^ ...because associated function `foo` has no `self` parameter |
36 | help: consider turning `foo` into a method by giving it a `&self` argument | |
74b04a01 | 37 | | |
29967ef6 | 38 | LL | fn foo(&self) -> Self; |
94222f64 | 39 | | +++++ |
29967ef6 | 40 | help: alternatively, consider constraining `foo` so it does not apply to trait objects |
74b04a01 XL |
41 | | |
42 | LL | fn foo() -> Self where Self: Sized; | |
94222f64 | 43 | | +++++++++++++++++ |
dfeec247 XL |
44 | |
45 | error: aborting due to 2 previous errors | |
46 | ||
47 | For more information about this error, try `rustc --explain E0038`. |