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