2021-12-16 20:03:59 -06:00
|
|
|
#![warn(clippy::iter_skip_next)]
|
2023-08-24 18:13:35 -05:00
|
|
|
#![allow(dead_code, clippy::iter_out_of_bounds)]
|
2023-07-27 06:40:22 -05:00
|
|
|
//@no-rustfix
|
2021-12-16 20:03:59 -06:00
|
|
|
/// Checks implementation of `ITER_SKIP_NEXT` lint
|
|
|
|
fn main() {
|
|
|
|
// fix #8128
|
|
|
|
let test_string = "1|1 2";
|
|
|
|
let sp = test_string.split('|').map(|s| s.trim());
|
|
|
|
let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect();
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: called `skip(..).next()` on an iterator
|
2021-12-16 20:03:59 -06:00
|
|
|
if let Some(s) = Some(test_string.split('|').map(|s| s.trim())) {
|
|
|
|
let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect();
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: called `skip(..).next()` on an iterator
|
2021-12-16 20:03:59 -06:00
|
|
|
};
|
|
|
|
fn check<T>(s: T)
|
|
|
|
where
|
|
|
|
T: Iterator<Item = String>,
|
|
|
|
{
|
|
|
|
let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect();
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: called `skip(..).next()` on an iterator
|
2021-12-16 20:03:59 -06:00
|
|
|
}
|
|
|
|
}
|