rust/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
387 B
Rust
Raw Normal View History

2021-06-27 01:22:46 -05:00
// edition:2021
2020-11-25 14:15:55 -06:00
// run-pass
// Tests that if a closure uses individual fields of the same object
2020-11-25 14:15:55 -06:00
// 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");
};
}