]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-ret-borrowed-1.rs
add UI test + docs for `E0789`
[rust.git] / tests / ui / regions / regions-ret-borrowed-1.rs
1 // Similar to regions-ret-borrowed.rs, but using a named lifetime.  At
2 // some point regions-ret-borrowed reported an error but this file did
3 // not, due to special hardcoding around the anonymous region.
4
5 fn with<R, F>(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R {
6     f(&3)
7 }
8
9 fn return_it<'a>() -> &'a isize {
10     with(|o| o)
11     //~^ ERROR lifetime may not live long enough
12 }
13
14 fn main() {
15     let x = return_it();
16     println!("foo={}", *x);
17 }