]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | #![warn(clippy::map_identity)] | |
3 | #![allow(clippy::needless_return)] | |
4 | ||
5 | fn main() { | |
6 | let x: [u16; 3] = [1, 2, 3]; | |
7 | // should lint | |
8 | let _: Vec<_> = x.iter().map(not_identity).collect(); | |
9 | let _: Vec<_> = x.iter().collect(); | |
10 | let _: Option<u8> = Some(3); | |
11 | let _: Result<i8, f32> = Ok(-3); | |
12 | // should not lint | |
13 | let _: Vec<_> = x.iter().map(|x| 2 * x).collect(); | |
14 | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x - 4).collect(); | |
15 | let _: Option<u8> = None.map(|x: u8| x - 1); | |
16 | let _: Result<i8, f32> = Err(2.3).map(|x: i8| { | |
17 | return x + 3; | |
18 | }); | |
19 | } | |
20 | ||
21 | fn not_identity(x: &u16) -> u16 { | |
22 | *x | |
23 | } |