about summary refs log tree commit diff
path: root/tests/ui/regions/regions-infer-reborrow-ref-mut-recurse.rs
blob: f4e5c3a93a6534b765ed94686af9ac5c040cd0b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//@ run-pass
#![allow(dead_code)]
// Test an edge case in region inference: the lifetime of the borrow
// of `*x` must be extended to at least 'a.


fn foo<'a,'b>(x: &'a &'b mut isize) -> &'a isize {
    let y = &*x; // should be inferred to have type &'a &'b mut isize...

    // ...because if we inferred, say, &'x &'b mut isize where 'x <= 'a,
    // this reborrow would be illegal:
    &**y
}

pub fn main() {
    /* Just want to know that it compiles. */
}