]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.rs
Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup
[rust.git] / tests / ui / suggestions / match-with-different-arm-types-as-stmt-instead-of-expr.rs
1 pub trait Foo {}
2
3 struct Bar;
4 struct Baz;
5
6 impl Foo for Bar { }
7 impl Foo for Baz { }
8
9 fn not_all_paths(a: &str) -> u32 { //~ ERROR mismatched types
10     match a {
11         "baz" => 0,
12         _ => 1,
13     };
14 }
15
16 fn right(b: &str) -> Box<dyn Foo> {
17     match b {
18         "baz" => Box::new(Baz),
19         _ => Box::new(Bar),
20     }
21 }
22
23 fn wrong(c: &str) -> Box<dyn Foo> { //~ ERROR mismatched types
24     match c {
25         "baz" => Box::new(Baz),
26         _ => Box::new(Bar), //~ ERROR `match` arms have incompatible types
27     };
28 }
29
30 fn main() {}