blob: 0360ce6e6b84cec397c330547f68b229e6a6f7fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
pub trait Foo {}
struct Bar;
struct Baz;
impl Foo for Bar { }
impl Foo for Baz { }
fn not_all_paths(a: &str) -> u32 { //~ ERROR mismatched types
match a {
"baz" => 0,
_ => 1,
};
}
fn right(b: &str) -> Box<dyn Foo> {
match b {
"baz" => Box::new(Baz),
_ => Box::new(Bar),
}
}
fn wrong(c: &str) -> Box<dyn Foo> { //~ ERROR mismatched types
match c {
"baz" => Box::new(Baz),
_ => Box::new(Bar), //~ ERROR `match` arms have incompatible types
};
}
fn main() {}
|