]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/iter_skip_next.rs
Auto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisa
[rust.git] / src / tools / clippy / tests / ui / iter_skip_next.rs
1 // run-rustfix
2 // aux-build:option_helpers.rs
3
4 #![warn(clippy::iter_skip_next)]
5 #![allow(clippy::disallowed_names)]
6 #![allow(clippy::iter_nth)]
7 #![allow(unused_mut, dead_code)]
8
9 extern crate option_helpers;
10
11 use option_helpers::IteratorFalsePositives;
12
13 /// Checks implementation of `ITER_SKIP_NEXT` lint
14 fn main() {
15     let some_vec = vec![0, 1, 2, 3];
16     let _ = some_vec.iter().skip(42).next();
17     let _ = some_vec.iter().cycle().skip(42).next();
18     let _ = (1..10).skip(10).next();
19     let _ = &some_vec[..].iter().skip(3).next();
20     let foo = IteratorFalsePositives { foo: 0 };
21     let _ = foo.skip(42).next();
22     let _ = foo.filter().skip(42).next();
23
24     // fix #8128
25     let test_string = "1|1 2";
26     let mut sp = test_string.split('|').map(|s| s.trim());
27     let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect();
28     if let Some(mut s) = Some(test_string.split('|').map(|s| s.trim())) {
29         let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect();
30     };
31     fn check<T>(mut s: T)
32     where
33         T: Iterator<Item = String>,
34     {
35         let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect();
36     }
37 }