]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/object-unsafe-trait-references-self.stderr
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / object-unsafe-trait-references-self.stderr
1 error[E0038]: the trait `Trait` cannot be made into an object
2   --> $DIR/object-unsafe-trait-references-self.rs:6:12
3    |
4 LL | fn bar(x: &dyn Trait) {}
5    |            ^^^^^^^^^ `Trait` 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-references-self.rs:2:22
9    |
10 LL | trait Trait {
11    |       ----- this trait cannot be made into an object...
12 LL |     fn baz(&self, _: Self) {}
13    |                      ^^^^ ...because method `baz` references the `Self` type in this parameter
14 LL |     fn bat(&self) -> Self {}
15    |                      ^^^^ ...because method `bat` references the `Self` type in its return type
16    = help: consider moving `baz` to another trait
17    = help: consider moving `bat` to another trait
18
19 error[E0038]: the trait `Other` cannot be made into an object
20   --> $DIR/object-unsafe-trait-references-self.rs:10:12
21    |
22 LL | fn foo(x: &dyn Other) {}
23    |            ^^^^^^^^^ `Other` cannot be made into an object
24    |
25 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>
26   --> $DIR/object-unsafe-trait-references-self.rs:8:14
27    |
28 LL | trait Other: Sized {}
29    |       -----  ^^^^^ ...because it requires `Self: Sized`
30    |       |
31    |       this trait cannot be made into an object...
32
33 error: aborting due to 2 previous errors
34
35 For more information about this error, try `rustc --explain E0038`.