rust/tests/ui/regions/regions-escape-via-trait-or-not.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
336 B
Rust
Raw Normal View History

#![allow(dead_code)]
trait Deref {
fn get(self) -> isize;
}
impl<'a> Deref for &'a isize {
fn get(self) -> isize {
*self
}
}
fn with<R:Deref, F>(f: F) -> isize where F: FnOnce(&isize) -> R {
f(&3).get()
}
fn return_it() -> isize {
2020-05-20 17:58:41 +00:00
with(|o| o) //~ ERROR lifetime may not live long enough
}
fn main() {
}