3 // - takes an argument `y`
4 // - stores `y` into another, longer-lived spot
6 // but is invoked with a spot that doesn't live long
7 // enough to store `y`.
9 // The error is reported in the caller: invoking the closure links the
10 // lifetime of the variable that is given as `y` (via subtyping) and
11 // thus forces the corresponding borrow to live too long. This is
12 // basically checking that the MIR type checker correctly enforces the
15 // compile-flags:-Zborrowck=mir -Zverbose
17 #![feature(rustc_attrs)]
26 let mut closure = expect_sig(|p, y| *p = y);
28 //~^ ERROR `y` does not live long enough [E0597]
34 fn expect_sig<F>(f: F) -> F
35 where F: for<'a, 'b> FnMut(&'a mut &'b i32, &'b i32)
40 fn deref(_p: &i32) { }