]> git.lizzy.rs Git - rust.git/blob - src/test/ui/if/if-without-else-as-fn-expr.stderr
a62a2cc1522a7ffbd2a323b4b6067a5def1cb72f
[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 unit 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 unit 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 unit 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[E0317]: if may be missing an else clause
48   --> $DIR/if-without-else-as-fn-expr.rs:24:5
49    |
50 LL |   fn foo_let(bar: usize) -> usize {
51    |                             ----- expected `usize` because of this return type
52 LL | /     if let 0 = 1 {
53 LL | |         return 3;
54 LL | |     }
55    | |_____^ expected usize, found ()
56    |
57    = note:   expected type `usize`
58            found unit type `()`
59    = note: `if` expressions without `else` evaluate to `()`
60    = help: consider adding an `else` block that evaluates to the expected type
61
62 error[E0317]: if may be missing an else clause
63   --> $DIR/if-without-else-as-fn-expr.rs:31:20
64    |
65 LL |       let x: usize = if let 0 = 1 {
66    |  _________-__________^
67    | |         |
68    | |         expected because of this assignment
69 LL | |         return 3;
70 LL | |     };
71    | |_____^ expected usize, found ()
72    |
73    = note:   expected type `usize`
74            found unit type `()`
75    = note: `if` expressions without `else` evaluate to `()`
76    = help: consider adding an `else` block that evaluates to the expected type
77
78 error[E0317]: if may be missing an else clause
79   --> $DIR/if-without-else-as-fn-expr.rs:39:5
80    |
81 LL |   fn foo3_let(bar: usize) -> usize {
82    |                              ----- expected `usize` because of this return type
83 LL | /     if let 0 = 1 {
84 LL | |         3
85 LL | |     }
86    | |_____^ expected usize, found ()
87    |
88    = note:   expected type `usize`
89            found unit type `()`
90    = note: `if` expressions without `else` evaluate to `()`
91    = help: consider adding an `else` block that evaluates to the expected type
92
93 error: aborting due to 6 previous errors
94
95 For more information about this error, try `rustc --explain E0317`.