fork/rust

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

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

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