| 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 |
fn foo<'a, 'b>(p: &'b &'a mut usize) -> &'b&'a mut usize { |
| 5 |
p |
| 6 |
} |
| 7 |
|
| 8 |
fn well_formed_function_inputs() { |
| 9 |
let s = &mut 1; |
| 10 |
let r = &mut *s; |
| 11 |
let tmp = foo(&r ); |
| 12 |
// let arg = &r; |
| 13 |
// let aarg = &*arg; |
| 14 |
// let tmp = arg; |
| 15 |
s; //~ ERROR |
| 16 |
// { dg-error "use of borrowed value" "" { target *-*-* } .-1 } |
| 17 |
tmp; |
| 18 |
/* |
| 19 |
{ dg-begin-multiline-output "" } |
| 20 |
NN | let r = &mut *s; |
| 21 |
| ~ |
| 22 |
| | |
| 23 |
| borrow occurs here |
| 24 |
...... |
| 25 |
NN | s; //~ ERROR |
| 26 |
| ^ |
| 27 |
| | |
| 28 |
| borrowed value used here |
| 29 |
{ dg-end-multiline-output "" } |
| 30 |
*/ |
| 31 |
} |