]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-reborrow-from-shorter-mut-ref.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-reborrow-from-shorter-mut-ref.rs
1 // Issue #8624. Tests that reborrowing the contents of an `&'b mut`
2 // pointer which is backed by another `&'a mut` can only be done
3 // for `'a` (which must be a sublifetime of `'b`).
4
5 fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize {
6     &mut **p
7     //~^ ERROR lifetime may not live long enough
8 }
9
10 fn main() {
11     let mut x = 1;
12     let mut y = &mut x;
13     let z = copy_borrowed_ptr(&mut y);
14     *y += 1;
15     *z += 1;
16 }