fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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