]> git.lizzy.rs Git - rust.git/blob - tests/ui/typeck/issue-100285.stderr
Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC
[rust.git] / tests / ui / typeck / issue-100285.stderr
1 error[E0308]: mismatched types
2   --> $DIR/issue-100285.rs:2:5
3    |
4 LL |   fn foo(n: i32) -> i32 {
5    |                     --- expected `i32` because of return type
6 LL | /     for i in 0..0 {
7 LL | |
8 LL | |        if n < 0 {
9 LL | |         return i;
10 ...  |
11 LL | |
12 LL | |     }
13    | |_____^ expected `i32`, found `()`
14    |
15 note: the function expects a value to always be returned, but loops might run zero times
16   --> $DIR/issue-100285.rs:2:5
17    |
18 LL |     for i in 0..0 {
19    |     ^^^^^^^^^^^^^ this might have zero elements to iterate on
20 ...
21 LL |         return i;
22    |         -------- if the loop doesn't execute, this value would never get returned
23 LL |         } else if n < 10 {
24 LL |           return 1;
25    |           -------- if the loop doesn't execute, this value would never get returned
26 LL |         } else if n < 20 {
27 LL |           return 2;
28    |           -------- if the loop doesn't execute, this value would never get returned
29    = note: if the loop doesn't execute, 3 other values would never get returned
30    = help: return a value for the case when the loop has zero elements to iterate on, or consider changing the return type to account for that possibility
31
32 error: aborting due to previous error
33
34 For more information about this error, try `rustc --explain E0308`.