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