]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/regions/regions-ret-borrowed.rs
1 // Ensure that you cannot use generic types to return a region outside
2 // of its bound. Here, in the `return_it()` fn, we call with() but
3 // with R bound to &isize from the return_it. Meanwhile, with()
4 // provides a value that is only good within its own stack frame. This
5 // used to successfully compile because we failed to account for the
6 // fact that fn(x: &isize) rebound the region &.
8 fn with
<R
, F
>(f
: F
) -> R
where F
: FnOnce(&isize) -> R
{
12 fn return_it
<'a
>() -> &'a
isize {
14 //~^ ERROR lifetime may not live long enough
19 println
!("foo={}", *x
);