about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/needless_update.rs
blob: 62e3492343193a5ee81c4265a65b0e575d6d8b84 (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
#![warn(clippy::needless_update)]
#![allow(clippy::no_effect, clippy::unnecessary_struct_initialization)]

struct S {
    pub a: i32,
    pub b: i32,
}

#[non_exhaustive]
struct T {
    pub x: i32,
    pub y: i32,
}

fn main() {
    let base = S { a: 0, b: 0 };
    S { ..base }; // no error
    S { a: 1, ..base }; // no error
    S { a: 1, b: 1, ..base };
    //~^ needless_update

    let base = T { x: 0, y: 0 };
    T { ..base }; // no error
    T { x: 1, ..base }; // no error
    T { x: 1, y: 1, ..base }; // no error
}