Debian Codegraph @

gcc/testsuite/rust/borrowck/use_while_mut.rs

raw
1 // { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" }
2 // { dg-enable-nn-line-numbers "" }
3
4 pub fn use_while_mut() {
5 let mut x = 0;
6 let y = &mut x;
7 let z = x; //~ ERROR
8 // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
9 let w = y;
10 /*
11 { dg-begin-multiline-output "" }
12 NN | let y = &mut x;
13 | ~
14 | |
15 | borrow occurs here
16 NN | let z = x; //~ ERROR
17 | ^
18 | |
19 | borrowed value used here
20 { dg-end-multiline-output "" }
21 */
22 }