]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / impl-trait / object-unsafe-trait-in-return-position-dyn-trait.stderr
CommitLineData
dfeec247 1error[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
4LL | fn car() -> dyn NotObjectSafe {
5 | ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
6 |
7note: 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
10LL | trait NotObjectSafe {
11 | ------------- this trait cannot be made into an object...
dfeec247 12LL | fn foo() -> Self;
29967ef6
XL
13 | ^^^ ...because associated function `foo` has no `self` parameter
14help: consider turning `foo` into a method by giving it a `&self` argument
74b04a01 15 |
29967ef6 16LL | fn foo(&self) -> Self;
94222f64 17 | +++++
29967ef6 18help: alternatively, consider constraining `foo` so it does not apply to trait objects
74b04a01
XL
19 |
20LL | fn foo() -> Self where Self: Sized;
94222f64 21 | +++++++++++++++++
dfeec247
XL
22
23error[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
26LL | fn cat() -> Box<dyn NotObjectSafe> {
27 | ^^^^^^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
28 |
29note: 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
32LL | trait NotObjectSafe {
33 | ------------- this trait cannot be made into an object...
dfeec247 34LL | fn foo() -> Self;
29967ef6
XL
35 | ^^^ ...because associated function `foo` has no `self` parameter
36help: consider turning `foo` into a method by giving it a `&self` argument
74b04a01 37 |
29967ef6 38LL | fn foo(&self) -> Self;
94222f64 39 | +++++
29967ef6 40help: alternatively, consider constraining `foo` so it does not apply to trait objects
74b04a01
XL
41 |
42LL | fn foo() -> Self where Self: Sized;
94222f64 43 | +++++++++++++++++
dfeec247
XL
44
45error: aborting due to 2 previous errors
46
47For more information about this error, try `rustc --explain E0038`.