]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[rust.git] / src / test / ui / impl-trait / object-unsafe-trait-in-return-position-dyn-trait.stderr
1 error[E0038]: the trait `NotObjectSafe` cannot be made into an object
2   --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:21:13
3    |
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    |
10 LL | trait NotObjectSafe {
11    |       ------------- this trait cannot be made into an object...
12 LL |     fn foo() -> Self;
13    |        ^^^ ...because associated function `foo` has no `self` parameter
14 help: consider turning `foo` into a method by giving it a `&self` argument
15    |
16 LL |     fn foo(&self) -> Self;
17    |            +++++
18 help: alternatively, consider constraining `foo` so it does not apply to trait objects
19    |
20 LL |     fn foo() -> Self where Self: Sized;
21    |                      +++++++++++++++++
22
23 error[E0038]: the trait `NotObjectSafe` cannot be made into an object
24   --> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:28:17
25    |
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    |
32 LL | trait NotObjectSafe {
33    |       ------------- this trait cannot be made into an object...
34 LL |     fn foo() -> Self;
35    |        ^^^ ...because associated function `foo` has no `self` parameter
36 help: consider turning `foo` into a method by giving it a `&self` argument
37    |
38 LL |     fn foo(&self) -> Self;
39    |            +++++
40 help: alternatively, consider constraining `foo` so it does not apply to trait objects
41    |
42 LL |     fn foo() -> Self where Self: Sized;
43    |                      +++++++++++++++++
44
45 error: aborting due to 2 previous errors
46
47 For more information about this error, try `rustc --explain E0038`.