]>
Commit | Line | Data |
---|---|---|
6a06907d XL |
1 | error[E0308]: mismatched types |
2 | --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:9:30 | |
3 | | | |
4 | LL | fn not_all_paths(a: &str) -> u32 { | |
5 | | ------------- ^^^ expected `u32`, found `()` | |
6 | | | | |
7 | | implicitly returns `()` as its body has no tail or `return` expression | |
8 | ... | |
9 | LL | }; | |
04454e1e | 10 | | - help: remove this semicolon |
6a06907d XL |
11 | |
12 | error[E0308]: `match` arms have incompatible types | |
13 | --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:26:14 | |
14 | | | |
15 | LL | / match c { | |
16 | LL | | "baz" => Box::new(Baz), | |
17 | | | ------------- this is found to be of type `Box<Baz>` | |
18 | LL | | _ => Box::new(Bar), | |
19 | | | ^^^^^^^^^^^^^ expected struct `Baz`, found struct `Bar` | |
20 | LL | | }; | |
21 | | |_____- `match` arms have incompatible types | |
22 | | | |
04454e1e FG |
23 | = note: expected struct `Box<Baz>` |
24 | found struct `Box<Bar>` | |
6a06907d XL |
25 | note: you might have meant to return the `match` expression |
26 | --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:27:6 | |
27 | | | |
28 | LL | fn wrong(c: &str) -> Box<dyn Foo> { | |
29 | | ------------ the `match` arms can conform to this return type | |
30 | LL | / match c { | |
31 | LL | | "baz" => Box::new(Baz), | |
32 | LL | | _ => Box::new(Bar), | |
33 | LL | | }; | |
34 | | | -^ the `match` is a statement because of this semicolon, consider removing it | |
35 | | |_____| | |
36 | | this could be implicitly returned but it is a statement, not a tail expression | |
37 | ||
38 | error[E0308]: mismatched types | |
39 | --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:23:22 | |
40 | | | |
41 | LL | fn wrong(c: &str) -> Box<dyn Foo> { | |
42 | | ----- ^^^^^^^^^^^^ expected struct `Box`, found `()` | |
43 | | | | |
44 | | implicitly returns `()` as its body has no tail or `return` expression | |
45 | | | |
46 | = note: expected struct `Box<(dyn Foo + 'static)>` | |
47 | found unit type `()` | |
48 | ||
49 | error: aborting due to 3 previous errors | |
50 | ||
51 | For more information about this error, try `rustc --explain E0308`. |