1 error[E0308]: mismatched types
2 --> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:36:5
4 LL | fn can() -> impl NotObjectSafe {
5 | ------------------ expected because this return type...
8 | - ...is found to be `A` here
11 | ^ expected struct `A`, found struct `B`
13 = note: to return `impl Trait`, all returned values must be of the same type
14 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
15 = help: if the trait `NotObjectSafe` were object safe, you could return a boxed trait object
16 = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
17 = help: alternatively, create a new `enum` with a variant for each returned type
19 error[E0308]: mismatched types
20 --> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:43:5
22 LL | fn cat() -> impl ObjectSafe {
23 | --------------- expected because this return type...
26 | - ...is found to be `A` here
29 | ^ expected struct `A`, found struct `B`
31 = note: to return `impl Trait`, all returned values must be of the same type
32 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
33 = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
34 = help: alternatively, create a new `enum` with a variant for each returned type
35 help: you could change the return type to be a boxed trait object
37 LL | fn cat() -> Box<dyn ObjectSafe> {
40 error: aborting due to 2 previous errors
42 For more information about this error, try `rustc --explain E0308`.