]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-30104.rs
Auto merge of #103600 - compiler-errors:early-binder-nits, r=spastorino
[rust.git] / src / test / ui / nll / issue-30104.rs
1 // Regression test for #30104
2
3 // check-pass
4
5 use std::ops::{Deref, DerefMut};
6
7 fn box_two_field(v: &mut Box<(i32, i32)>) {
8     let _a = &mut v.0;
9     let _b = &mut v.1;
10 }
11
12 fn box_destructure(v: &mut Box<(i32, i32)>) {
13     let (ref mut _head, ref mut _tail) = **v;
14 }
15
16 struct Wrap<T>(T);
17
18 impl<T> Deref for Wrap<T> {
19     type Target = T;
20     fn deref(&self) -> &T {
21         &self.0
22     }
23 }
24
25 impl<T> DerefMut for Wrap<T> {
26     fn deref_mut(&mut self) -> &mut T {
27         &mut self.0
28     }
29 }
30
31 fn smart_two_field(v: &mut Wrap<(i32, i32)>) {
32     let _a = &mut v.0;
33     let _b = &mut v.1;
34 }
35
36 fn smart_destructure(v: &mut Wrap<(i32, i32)>) {
37     let (ref mut _head, ref mut _tail) = **v;
38 }
39
40 fn main() {}