2013-11-16 16:30:45 -06:00
|
|
|
// Issue #8624. Tests that reborrowing the contents of an `&'b mut`
|
|
|
|
// pointer which is backed by another `&'a mut` can only be done
|
|
|
|
// for `'a` (which must be a sublifetime of `'b`).
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize {
|
2022-04-19 05:56:18 -05:00
|
|
|
&mut **p
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2013-11-16 16:30:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = 1;
|
|
|
|
let mut y = &mut x;
|
|
|
|
let z = copy_borrowed_ptr(&mut y);
|
|
|
|
*y += 1;
|
|
|
|
*z += 1;
|
|
|
|
}
|