summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/author/struct.rs
blob: 5fdf3433a3702de7b324580e6fd4b8f386403914 (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
35
36
37
38
39
40
#[allow(clippy::unnecessary_operation, clippy::single_match)]
fn main() {
    struct Test {
        field: u32,
    }

    #[clippy::author]
    Test {
        field: if true { 1 } else { 0 },
    };

    let test = Test { field: 1 };

    match test {
        #[clippy::author]
        Test { field: 1 } => {},
        _ => {},
    }

    struct TestTuple(u32);

    let test_tuple = TestTuple(1);

    match test_tuple {
        #[clippy::author]
        TestTuple(1) => {},
        _ => {},
    }

    struct TestMethodCall(u32);

    impl TestMethodCall {
        fn test(&self) {}
    }

    let test_method_call = TestMethodCall(1);

    #[clippy::author]
    test_method_call.test();
}