summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/needless_update.rs
blob: b93ff048a62f21de1f957e5c1df595552dae851d (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
#![warn(clippy::needless_update)]
#![allow(clippy::no_effect)]

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 };

    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
}