diff options
Diffstat (limited to 'tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs')
-rw-r--r-- | tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs b/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs new file mode 100644 index 000000000..03400e0ee --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs @@ -0,0 +1,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"); + }; +} |