]> git.lizzy.rs Git - rust.git/blob - tests/ui/mismatched_types/do-not-suggest-boxed-trait-objects-instead-of-impl-trait.rs
Rollup merge of #106712 - Ezrashaw:impl-ref-trait, r=estebank
[rust.git] / tests / ui / mismatched_types / do-not-suggest-boxed-trait-objects-instead-of-impl-trait.rs
1 struct S;
2 struct Y;
3
4 trait Trait {}
5
6 impl Trait for Y {}
7
8 fn foo() -> impl Trait {
9     if true {
10         S
11     } else {
12         Y //~ ERROR `if` and `else` have incompatible types
13     }
14 }
15
16 fn bar() -> impl Trait {
17     match true {
18         true => S,
19         false => Y, //~ ERROR `match` arms have incompatible types
20     }
21 }
22
23 fn main() {}