Skip to content

Commit e9f56f9

Browse files
committed
Add false positive test for iterator method
1 parent b4d76b4 commit e9f56f9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

tests/ui/auxiliary/option_helpers.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@ impl IteratorFalsePositives {
5353
self.foo as usize
5454
}
5555
}
56+
57+
#[derive(Copy, Clone)]
58+
pub struct IteratorMethodFalsePositives;
59+
60+
impl IteratorMethodFalsePositives {
61+
pub fn filter(&self, _s: i32) -> std::vec::IntoIter<i32> {
62+
unimplemented!();
63+
}
64+
}

tests/ui/methods.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::ops::Mul;
3232
use std::rc::{self, Rc};
3333
use std::sync::{self, Arc};
3434

35-
use option_helpers::IteratorFalsePositives;
35+
use option_helpers::{IteratorFalsePositives, IteratorMethodFalsePositives};
3636

3737
struct Lt<'a> {
3838
foo: &'a u32,
@@ -131,6 +131,9 @@ fn filter_next() {
131131
// Check that we don't lint if the caller is not an `Iterator`.
132132
let foo = IteratorFalsePositives { foo: 0 };
133133
let _ = foo.filter().next();
134+
135+
let foo = IteratorMethodFalsePositives {};
136+
let _ = foo.filter(42).next();
134137
}
135138

136139
fn main() {

0 commit comments

Comments
 (0)