]> git.proxmox.com Git - rustc.git/blame - src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / suggestions / match-with-different-arm-types-as-stmt-instead-of-expr.stderr
CommitLineData
6a06907d
XL
1error[E0308]: mismatched types
2 --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:9:30
3 |
4LL | 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...
9LL | };
04454e1e 10 | - help: remove this semicolon
6a06907d
XL
11
12error[E0308]: `match` arms have incompatible types
13 --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:26:14
14 |
15LL | / match c {
16LL | | "baz" => Box::new(Baz),
17 | | ------------- this is found to be of type `Box<Baz>`
18LL | | _ => Box::new(Bar),
19 | | ^^^^^^^^^^^^^ expected struct `Baz`, found struct `Bar`
20LL | | };
21 | |_____- `match` arms have incompatible types
22 |
04454e1e
FG
23 = note: expected struct `Box<Baz>`
24 found struct `Box<Bar>`
6a06907d
XL
25note: 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 |
28LL | fn wrong(c: &str) -> Box<dyn Foo> {
29 | ------------ the `match` arms can conform to this return type
30LL | / match c {
31LL | | "baz" => Box::new(Baz),
32LL | | _ => Box::new(Bar),
33LL | | };
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
38error[E0308]: mismatched types
39 --> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:23:22
40 |
41LL | 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
49error: aborting due to 3 previous errors
50
51For more information about this error, try `rustc --explain E0308`.