2023-04-20 14:37:15 +00:00
|
|
|
//@aux-build:option_helpers.rs
|
2020-07-25 14:09:44 +00:00
|
|
|
|
|
|
|
#![warn(clippy::iter_skip_next)]
|
2022-06-08 19:08:37 +00:00
|
|
|
#![allow(clippy::disallowed_names)]
|
2020-07-25 14:09:44 +00:00
|
|
|
#![allow(clippy::iter_nth)]
|
2023-06-06 20:56:57 +00:00
|
|
|
#![allow(clippy::useless_vec)]
|
2023-08-24 23:13:35 +00:00
|
|
|
#![allow(clippy::iter_out_of_bounds)]
|
2021-12-17 02:03:59 +00:00
|
|
|
#![allow(unused_mut, dead_code)]
|
2020-07-25 14:09:44 +00:00
|
|
|
|
|
|
|
extern crate option_helpers;
|
|
|
|
|
|
|
|
use option_helpers::IteratorFalsePositives;
|
|
|
|
|
|
|
|
/// Checks implementation of `ITER_SKIP_NEXT` lint
|
|
|
|
fn main() {
|
|
|
|
let some_vec = vec![0, 1, 2, 3];
|
|
|
|
let _ = some_vec.iter().nth(42);
|
|
|
|
let _ = some_vec.iter().cycle().nth(42);
|
|
|
|
let _ = (1..10).nth(10);
|
|
|
|
let _ = &some_vec[..].iter().nth(3);
|
|
|
|
let foo = IteratorFalsePositives { foo: 0 };
|
|
|
|
let _ = foo.skip(42).next();
|
|
|
|
let _ = foo.filter().skip(42).next();
|
2021-12-17 02:03:59 +00:00
|
|
|
|
|
|
|
// fix #8128
|
|
|
|
let test_string = "1|1 2";
|
|
|
|
let mut sp = test_string.split('|').map(|s| s.trim());
|
|
|
|
let _: Vec<&str> = sp.nth(1).unwrap().split(' ').collect();
|
|
|
|
if let Some(mut s) = Some(test_string.split('|').map(|s| s.trim())) {
|
|
|
|
let _: Vec<&str> = s.nth(1).unwrap().split(' ').collect();
|
|
|
|
};
|
|
|
|
fn check<T>(mut s: T)
|
|
|
|
where
|
|
|
|
T: Iterator<Item = String>,
|
|
|
|
{
|
|
|
|
let _: Vec<&str> = s.nth(1).unwrap().split(' ').collect();
|
|
|
|
}
|
2020-07-25 14:09:44 +00:00
|
|
|
}
|