fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69854 - pietroalbini:stable-next, r=Centrilb8cedc00407

1.42.0
2.9 KiB83 linesraw
1error[E0317]: `if` may be missing an `else` clause
2  --> $DIR/if-without-else-as-fn-expr.rs:2:5
3   |
4LL |   fn foo(bar: usize) -> usize {
5   |                         ----- expected `usize` because of this return type
6LL | /     if bar % 5 == 0 {
7LL | |         return 3;
8LL | |     }
9   | |_____^ expected `usize`, found `()`
10   |
11   = note: `if` expressions without `else` evaluate to `()`
12   = help: consider adding an `else` block that evaluates to the expected type
13
14error[E0317]: `if` may be missing an `else` clause
15  --> $DIR/if-without-else-as-fn-expr.rs:9:20
16   |
17LL |       let x: usize = if bar % 5 == 0 {
18   |  _________-__________^
19   | |         |
20   | |         expected because of this assignment
21LL | |         return 3;
22LL | |     };
23   | |_____^ expected `usize`, found `()`
24   |
25   = note: `if` expressions without `else` evaluate to `()`
26   = help: consider adding an `else` block that evaluates to the expected type
27
28error[E0317]: `if` may be missing an `else` clause
29  --> $DIR/if-without-else-as-fn-expr.rs:17:5
30   |
31LL |   fn foo3(bar: usize) -> usize {
32   |                          ----- expected `usize` because of this return type
33LL | /     if bar % 5 == 0 {
34LL | |         3
35LL | |     }
36   | |_____^ expected `usize`, found `()`
37   |
38   = note: `if` expressions without `else` evaluate to `()`
39   = help: consider adding an `else` block that evaluates to the expected type
40
41error[E0317]: `if` may be missing an `else` clause
42  --> $DIR/if-without-else-as-fn-expr.rs:24:5
43   |
44LL |   fn foo_let(bar: usize) -> usize {
45   |                             ----- expected `usize` because of this return type
46LL | /     if let 0 = 1 {
47LL | |         return 3;
48LL | |     }
49   | |_____^ expected `usize`, found `()`
50   |
51   = note: `if` expressions without `else` evaluate to `()`
52   = help: consider adding an `else` block that evaluates to the expected type
53
54error[E0317]: `if` may be missing an `else` clause
55  --> $DIR/if-without-else-as-fn-expr.rs:31:20
56   |
57LL |       let x: usize = if let 0 = 1 {
58   |  _________-__________^
59   | |         |
60   | |         expected because of this assignment
61LL | |         return 3;
62LL | |     };
63   | |_____^ expected `usize`, found `()`
64   |
65   = note: `if` expressions without `else` evaluate to `()`
66   = help: consider adding an `else` block that evaluates to the expected type
67
68error[E0317]: `if` may be missing an `else` clause
69  --> $DIR/if-without-else-as-fn-expr.rs:39:5
70   |
71LL |   fn foo3_let(bar: usize) -> usize {
72   |                              ----- expected `usize` because of this return type
73LL | /     if let 0 = 1 {
74LL | |         3
75LL | |     }
76   | |_____^ expected `usize`, found `()`
77   |
78   = note: `if` expressions without `else` evaluate to `()`
79   = help: consider adding an `else` block that evaluates to the expected type
80
81error: aborting due to 6 previous errors
82
83For more information about this error, try `rustc --explain E0317`.