about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.rs
blob: 6d28d544dfe0b9129360711e05452b452380b31e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![warn(clippy::unnecessary_lazy_evaluations)]
#![allow(clippy::unnecessary_literal_unwrap)]
//@no-rustfix
struct Deep(Option<usize>);

#[derive(Copy, Clone)]
struct SomeStruct {
    some_field: usize,
}

fn main() {
    // fix will break type inference
    let _ = Ok(1).unwrap_or_else(|()| 2);
    //~^ unnecessary_lazy_evaluations

    mod e {
        pub struct E;
    }
    let _ = Ok(1).unwrap_or_else(|e::E| 2);
    //~^ unnecessary_lazy_evaluations

    let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2);
    //~^ unnecessary_lazy_evaluations

    // Fix #6343
    let arr = [(Some(1),)];
    Some(&0).and_then(|&i| arr[i].0);
}

fn issue11672() {
    // Return type annotation helps type inference and removing it can break code
    let _ = true.then(|| -> &[u8] { &[] });
    //~^ unnecessary_lazy_evaluations
}