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