File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // Regression test for #30104
12+
13+ // compile-pass
14+
15+ #![ feature( nll) ]
16+
17+ use std:: ops:: { Deref , DerefMut } ;
18+
19+ fn box_two_field ( v : & mut Box < ( i32 , i32 ) > ) {
20+ let _a = & mut v. 0 ;
21+ let _b = & mut v. 1 ;
22+ }
23+
24+ fn box_destructure ( v : & mut Box < ( i32 , i32 ) > ) {
25+ let ( ref mut _head, ref mut _tail) = * * v;
26+ }
27+
28+ struct Wrap < T > ( T ) ;
29+
30+ impl < T > Deref for Wrap < T > {
31+ type Target = T ;
32+ fn deref ( & self ) -> & T {
33+ & self . 0
34+ }
35+ }
36+
37+ impl < T > DerefMut for Wrap < T > {
38+ fn deref_mut ( & mut self ) -> & mut T {
39+ & mut self . 0
40+ }
41+ }
42+
43+ fn smart_two_field ( v : & mut Wrap < ( i32 , i32 ) > ) {
44+ let _a = & mut v. 0 ;
45+ let _b = & mut v. 1 ;
46+ }
47+
48+ fn smart_destructure ( v : & mut Wrap < ( i32 , i32 ) > ) {
49+ let ( ref mut _head, ref mut _tail) = * * v;
50+ }
51+
52+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments