]> git.lizzy.rs Git - rust.git/blob - tests/ui/mismatched_types/suggest-boxed-trait-objects-instead-of-impl-trait.rs
Auto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank...
[rust.git] / tests / ui / mismatched_types / suggest-boxed-trait-objects-instead-of-impl-trait.rs
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() -> impl Trait {
14     if true {
15         S
16     } else {
17         Y //~ ERROR `if` and `else` have incompatible types
18     }
19 }
20
21 fn bar() -> impl Trait {
22     match true {
23         true => S,
24         false => Y, //~ ERROR `match` arms have incompatible types
25     }
26 }
27
28 fn main() {}