1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// SPDX-License-Identifier: Apache-2.0 OR MIT
use auto_enums::auto_enum;
#[auto_enum(Iterator)]
fn if_missing_else(x: usize) -> impl Iterator<Item = i32> {
if x == 0 {
1..8
} else if x > 3 {
//~^ ERROR `if` expression missing an else clause
2..=10
}
}
#[auto_enum(Iterator)]
fn return1(x: i32, y: i32) -> impl Iterator<Item = i32> {
#[auto_enum(Iterator)]
let iter = match x {
//~^ ERROR `#[auto_enum]` is required two or more branches or marker macros in total, there is only one branch or marker macro in this statement
_ if y < 0 => return y..=0,
_ => 2..=10,
};
match y {
0 => iter.flat_map(|x| 0..x),
_ => iter.map(|x| x + 1),
}
}
#[auto_enum(Iterator)]
fn return0(x: i32, y: i32) -> impl Iterator<Item = i32> {
#[auto_enum(Iterator)]
let iter = match x {
//~^ ERROR `#[auto_enum]` is required two or more branches or marker macros in total, there is no branch or marker macro in this statement
_ if y < 0 => return y..=0,
_ => return 2..=10,
};
match y {
0 => iter.flat_map(|x| 0..x),
_ => iter.map(|x| x + 1),
}
}
#[auto_enum(Iterator)]
fn multi_error(x: i32, y: i32) -> impl Iterator<Item = i32> {
#[auto_enum(Iterator)]
let iter = match x {
//~^ ERROR `#[auto_enum]` is required two or more branches or marker macros in total, there is only one branch or marker macro in this statement
_ if y < 0 => return y..=0,
_ => {
#[auto_enum(Iterator)]
let _iter = match x {
//~^ ERROR `#[auto_enum]` is required two or more branches or marker macros in total, there is only one branch or marker macro in this statement
_ if y < 0 => return y..=0,
_ => 2..=10,
};
2..=10
}
};
match y {
0 => iter.flat_map(|x| 0..x),
_ => iter.map(|x| x + 1),
}
}
fn main() {}