1 error[E0308]: `if` and `else` have incompatible types
2 --> $DIR/suggest-boxed-trait-objects-instead-of-impl-trait.rs:17:9
6 | | - expected because of this
9 | | ^ expected struct `S`, found struct `Y`
11 | |_____- `if` and `else` have incompatible types
13 help: you could change the return type to be a boxed trait object
15 LL | fn foo() -> Box<dyn Trait> {
17 help: if you change the return type to expect trait objects, box the returned expressions
24 error[E0308]: `match` arms have incompatible types
25 --> $DIR/suggest-boxed-trait-objects-instead-of-impl-trait.rs:24:18
29 | | - this is found to be of type `S`
31 | | ^ expected struct `S`, found struct `Y`
33 | |_____- `match` arms have incompatible types
35 help: you could change the return type to be a boxed trait object
37 LL | fn bar() -> Box<dyn Trait> {
39 help: if you change the return type to expect trait objects, box the returned expressions
41 LL ~ true => Box::new(S),
42 LL ~ false => Box::new(Y),
45 error: aborting due to 2 previous errors
47 For more information about this error, try `rustc --explain E0308`.