Add false positive test for iterator method

This commit is contained in:
dswij 2021-08-13 14:34:33 +08:00
parent b4d76b42fd
commit e9f56f949d
2 changed files with 13 additions and 1 deletions

View file

@ -53,3 +53,12 @@ impl IteratorFalsePositives {
self.foo as usize
}
}
#[derive(Copy, Clone)]
pub struct IteratorMethodFalsePositives;
impl IteratorMethodFalsePositives {
pub fn filter(&self, _s: i32) -> std::vec::IntoIter<i32> {
unimplemented!();
}
}

View file

@ -32,7 +32,7 @@ use std::ops::Mul;
use std::rc::{self, Rc};
use std::sync::{self, Arc};
use option_helpers::IteratorFalsePositives;
use option_helpers::{IteratorFalsePositives, IteratorMethodFalsePositives};
struct Lt<'a> {
foo: &'a u32,
@ -131,6 +131,9 @@ fn filter_next() {
// Check that we don't lint if the caller is not an `Iterator`.
let foo = IteratorFalsePositives { foo: 0 };
let _ = foo.filter().next();
let foo = IteratorMethodFalsePositives {};
let _ = foo.filter(42).next();
}
fn main() {