1+ error[E0308]: mismatched types
2+ --> $DIR/if-without-else-as-fn-expr.rs:2:5
3+ |
4+ LL | / if bar % 5 == 0 {
5+ LL | | return 3;
6+ LL | | }
7+ | |_____^ expected usize, found ()
8+ |
9+ = note: expected type `usize`
10+ found type `()`
11+
112error[E0317]: if may be missing an else clause
213 --> $DIR/if-without-else-as-fn-expr.rs:2:5
314 |
@@ -13,8 +24,20 @@ LL | | }
1324 = note: `if` expressions without `else` evaluate to `()`
1425 = help: consider adding an `else` block that evaluates to the expected type
1526
27+ error[E0308]: mismatched types
28+ --> $DIR/if-without-else-as-fn-expr.rs:10:20
29+ |
30+ LL | let x: usize = if bar % 5 == 0 {
31+ | ____________________^
32+ LL | | return 3;
33+ LL | | };
34+ | |_____^ expected usize, found ()
35+ |
36+ = note: expected type `usize`
37+ found type `()`
38+
1639error[E0317]: if may be missing an else clause
17- --> $DIR/if-without-else-as-fn-expr.rs:9 :20
40+ --> $DIR/if-without-else-as-fn-expr.rs:10 :20
1841 |
1942LL | let x: usize = if bar % 5 == 0 {
2043 | _________-__________^
@@ -29,8 +52,19 @@ LL | | };
2952 = note: `if` expressions without `else` evaluate to `()`
3053 = help: consider adding an `else` block that evaluates to the expected type
3154
55+ error[E0308]: mismatched types
56+ --> $DIR/if-without-else-as-fn-expr.rs:19:5
57+ |
58+ LL | / if bar % 5 == 0 {
59+ LL | | 3
60+ LL | | }
61+ | |_____^ expected usize, found ()
62+ |
63+ = note: expected type `usize`
64+ found type `()`
65+
3266error[E0317]: if may be missing an else clause
33- --> $DIR/if-without-else-as-fn-expr.rs:17 :5
67+ --> $DIR/if-without-else-as-fn-expr.rs:19 :5
3468 |
3569LL | fn foo3(bar: usize) -> usize {
3670 | ----- expected `usize` because of this return type
@@ -44,6 +78,87 @@ LL | | }
4478 = note: `if` expressions without `else` evaluate to `()`
4579 = help: consider adding an `else` block that evaluates to the expected type
4680
47- error: aborting due to 3 previous errors
81+ error[E0308]: mismatched types
82+ --> $DIR/if-without-else-as-fn-expr.rs:27:5
83+ |
84+ LL | / if let 0 = 1 {
85+ LL | | return 3;
86+ LL | | }
87+ | |_____^ expected usize, found ()
88+ |
89+ = note: expected type `usize`
90+ found type `()`
91+
92+ error[E0317]: if may be missing an else clause
93+ --> $DIR/if-without-else-as-fn-expr.rs:27:5
94+ |
95+ LL | fn foo_let(bar: usize) -> usize {
96+ | ----- expected `usize` because of this return type
97+ LL | / if let 0 = 1 {
98+ LL | | return 3;
99+ LL | | }
100+ | |_____^ expected usize, found ()
101+ |
102+ = note: expected type `usize`
103+ found type `()`
104+ = note: `if` expressions without `else` evaluate to `()`
105+ = help: consider adding an `else` block that evaluates to the expected type
106+
107+ error[E0308]: mismatched types
108+ --> $DIR/if-without-else-as-fn-expr.rs:35:20
109+ |
110+ LL | let x: usize = if let 0 = 1 {
111+ | ____________________^
112+ LL | | return 3;
113+ LL | | };
114+ | |_____^ expected usize, found ()
115+ |
116+ = note: expected type `usize`
117+ found type `()`
118+
119+ error[E0317]: if may be missing an else clause
120+ --> $DIR/if-without-else-as-fn-expr.rs:35:20
121+ |
122+ LL | let x: usize = if let 0 = 1 {
123+ | _________-__________^
124+ | | |
125+ | | expected because of this assignment
126+ LL | | return 3;
127+ LL | | };
128+ | |_____^ expected usize, found ()
129+ |
130+ = note: expected type `usize`
131+ found type `()`
132+ = note: `if` expressions without `else` evaluate to `()`
133+ = help: consider adding an `else` block that evaluates to the expected type
134+
135+ error[E0308]: mismatched types
136+ --> $DIR/if-without-else-as-fn-expr.rs:44:5
137+ |
138+ LL | / if let 0 = 1 {
139+ LL | | 3
140+ LL | | }
141+ | |_____^ expected usize, found ()
142+ |
143+ = note: expected type `usize`
144+ found type `()`
145+
146+ error[E0317]: if may be missing an else clause
147+ --> $DIR/if-without-else-as-fn-expr.rs:44:5
148+ |
149+ LL | fn foo3_let(bar: usize) -> usize {
150+ | ----- expected `usize` because of this return type
151+ LL | / if let 0 = 1 {
152+ LL | | 3
153+ LL | | }
154+ | |_____^ expected usize, found ()
155+ |
156+ = note: expected type `usize`
157+ found type `()`
158+ = note: `if` expressions without `else` evaluate to `()`
159+ = help: consider adding an `else` block that evaluates to the expected type
160+
161+ error: aborting due to 12 previous errors
48162
49- For more information about this error, try `rustc --explain E0317`.
163+ Some errors have detailed explanations: E0308, E0317.
164+ For more information about an error, try `rustc --explain E0308`.
0 commit comments