]> git.proxmox.com Git - rustc.git/blob - src/test/ui/closures/2229_closure_analysis/run_pass/capture-disjoint-field-tuple.rs
Merge tag 'debian/1.50.0+dfsg1-1_exp4' into debian/sid
[rustc.git] / src / test / ui / closures / 2229_closure_analysis / run_pass / capture-disjoint-field-tuple.rs
1 // run-pass
2
3 // Test that we can immutably borrow an element of a tuple from within a closure,
4 // while having a mutable borrow to another element of the same tuple outside the closure.
5
6 #![feature(capture_disjoint_fields)]
7 //~^ WARNING: the feature `capture_disjoint_fields` is incomplete
8 //~| NOTE: `#[warn(incomplete_features)]` on by default
9 //~| NOTE: see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
10 #![feature(rustc_attrs)]
11
12 fn main() {
13 let mut t = (10, 10);
14
15 let c = || {
16 println!("{}", t.0);
17 };
18
19 // `c` only captures t.0, therefore mutating t.1 is allowed.
20 let t1 = &mut t.1;
21
22 c();
23 *t1 = 20;
24 }