Skip to content

Commit 477b02a

Browse files
committed
Add tests for custom Some and None definitions
1 parent 4dbba64 commit 477b02a

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

tests/ui/iter_empty.fixed

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ macro_rules! in_macros {
2222
};
2323
}
2424

25+
// Don't trigger on a `None` that isn't std's option
26+
mod custom_option {
27+
#[allow(unused)]
28+
enum CustomOption {
29+
Some(i32),
30+
None,
31+
}
32+
33+
impl CustomOption {
34+
fn iter(&self) {}
35+
fn iter_mut(&mut self) {}
36+
fn into_iter(self) {}
37+
}
38+
use CustomOption::*;
39+
40+
pub fn custom_option() {
41+
None.iter();
42+
None.iter_mut();
43+
None.into_iter();
44+
}
45+
}
46+
2547
fn main() {
2648
array();
49+
custom_option::custom_option();
2750
in_macros!();
2851
}

tests/ui/iter_empty.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ macro_rules! in_macros {
2222
};
2323
}
2424

25+
// Don't trigger on a `None` that isn't std's option
26+
mod custom_option {
27+
#[allow(unused)]
28+
enum CustomOption {
29+
Some(i32),
30+
None,
31+
}
32+
33+
impl CustomOption {
34+
fn iter(&self) {}
35+
fn iter_mut(&mut self) {}
36+
fn into_iter(self) {}
37+
}
38+
use CustomOption::*;
39+
40+
pub fn custom_option() {
41+
None.iter();
42+
None.iter_mut();
43+
None.into_iter();
44+
}
45+
}
46+
2547
fn main() {
2648
array();
49+
custom_option::custom_option();
2750
in_macros!();
2851
}

tests/ui/iter_once.fixed

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ macro_rules! in_macros {
2222
};
2323
}
2424

25+
// Don't trigger on a `Some` that isn't std's option
26+
mod custom_option {
27+
#[allow(unused)]
28+
enum CustomOption {
29+
Some(i32),
30+
None,
31+
}
32+
33+
impl CustomOption {
34+
fn iter(&self) {}
35+
fn iter_mut(&mut self) {}
36+
fn into_iter(self) {}
37+
}
38+
use CustomOption::*;
39+
40+
pub fn custom_option() {
41+
Some(3).iter();
42+
Some(3).iter_mut();
43+
Some(3).into_iter();
44+
}
45+
}
46+
2547
fn main() {
2648
array();
49+
custom_option::custom_option();
2750
in_macros!();
2851
}

tests/ui/iter_once.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ macro_rules! in_macros {
2222
};
2323
}
2424

25+
// Don't trigger on a `Some` that isn't std's option
26+
mod custom_option {
27+
#[allow(unused)]
28+
enum CustomOption {
29+
Some(i32),
30+
None,
31+
}
32+
33+
impl CustomOption {
34+
fn iter(&self) {}
35+
fn iter_mut(&mut self) {}
36+
fn into_iter(self) {}
37+
}
38+
use CustomOption::*;
39+
40+
pub fn custom_option() {
41+
Some(3).iter();
42+
Some(3).iter_mut();
43+
Some(3).into_iter();
44+
}
45+
}
46+
2547
fn main() {
2648
array();
49+
custom_option::custom_option();
2750
in_macros!();
2851
}

0 commit comments

Comments
 (0)