Debian Codegraph @

gcc/testsuite/rust/borrowck/test_move_behind_reference.rs

raw
1 // { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck" }
2 fn test_move_behind_reference() {
3 // { dg-error "Cannot move from behind a reference." "" { target *-*-* } .-1 }
4 struct A {
5 i: i32,
6 }
7 struct B {
8 a: A,
9 }
10 let a = A { i: 1 };
11 let b = B { a };
12 let c = &b;
13 let d = c.a;
14 }
15
16 fn test_move_behind_reference_fixed() {
17 struct A {
18 i: i32,
19 }
20 struct B {
21 a: A,
22 }
23 let a = A { i: 1 };
24 let b = B { a };
25 let c = b;
26 let d = c.a;
27 }