]> git.lizzy.rs Git - rust.git/blob - src/test/ui/if/if-without-else-as-fn-expr.stderr
0ba72726ca78795807758c74146bb5ffa44189b3
[rust.git] / src / test / ui / if / if-without-else-as-fn-expr.stderr
1 error[E0317]: if may be missing an else clause
2   --> $DIR/if-without-else-as-fn-expr.rs:2:5
3    |
4 LL |   fn foo(bar: usize) -> usize {
5    |                         ----- expected `usize` because of this return type
6 LL | /     if bar % 5 == 0 {
7 LL | |         return 3;
8 LL | |     }
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
16 error[E0317]: if may be missing an else clause
17   --> $DIR/if-without-else-as-fn-expr.rs:9:20
18    |
19 LL |       let x: usize = if bar % 5 == 0 {
20    |  _________-__________^
21    | |         |
22    | |         expected because of this assignment
23 LL | |         return 3;
24 LL | |     };
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
32 error[E0317]: if may be missing an else clause
33   --> $DIR/if-without-else-as-fn-expr.rs:17:5
34    |
35 LL |   fn foo3(bar: usize) -> usize {
36    |                          ----- expected `usize` because of this return type
37 LL | /     if bar % 5 == 0 {
38 LL | |         3
39 LL | |     }
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
47 error: aborting due to 3 previous errors
48
49 For more information about this error, try `rustc --explain E0317`.