]> git.lizzy.rs Git - rust.git/blob - tests/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.fixed
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / mismatched_types / suggest-boxed-trait-objects-instead-of-impl-trait.fixed
1 // run-rustfix
2
3 #![allow(dead_code)]
4
5 struct S;
6 struct Y;
7
8 trait Trait {}
9
10 impl Trait for S {}
11 impl Trait for Y {}
12
13 fn foo() -> Box<dyn Trait> {
14     if true {
15         Box::new(S)
16     } else {
17         Box::new(Y) //~ ERROR `if` and `else` have incompatible types
18     }
19 }
20
21 fn bar() -> Box<dyn Trait> {
22     match true {
23         true => Box::new(S),
24         false => Box::new(Y), //~ ERROR `match` arms have incompatible types
25     }
26 }
27
28 fn main() {}