summaryrefslogtreecommitdiffstats
path: root/tests/ui/regions/regions-ret-borrowed-1.rs
blob: 54630caffb4c66fe3a97b11eb2d816f06cec5898 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Similar to regions-ret-borrowed.rs, but using a named lifetime.  At
// some point regions-ret-borrowed reported an error but this file did
// not, due to special hardcoding around the anonymous region.

fn with<R, F>(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R {
    f(&3)
}

fn return_it<'a>() -> &'a isize {
    with(|o| o)
    //~^ ERROR lifetime may not live long enough
}

fn main() {
    let x = return_it();
    println!("foo={}", *x);
}