summaryrefslogtreecommitdiffstats
path: root/src/test/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs
blob: 03400e0ee8d56fdd8bacc323eca72dbb49c25a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// edition:2021
// run-pass

// Tests that if a closure uses individual fields of the same object
// then that case is handled properly.

#![allow(unused)]

struct Struct {
    x: i32,
    y: i32,
    s: String,
}

fn main() {
    let mut s = Struct { x: 10, y: 10, s: String::new() };

    let mut c = {
        s.x += 10;
        s.y += 42;
        s.s = String::from("new");
    };
}