]> git.proxmox.com Git - rustc.git/blame - src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / nll / closure-requirements / escape-upvar-ref.rs
CommitLineData
ff7c6d11
XL
1// Test closure that:
2//
3// - captures a variable `y` by reference
4// - stores that reference to `y` into another, longer-lived place (`p`)
5//
6// Both of these are upvars of reference type (the capture of `y` is
7// of type `&'a i32`, the capture of `p` is of type `&mut &'b
8// i32`). The closure thus computes a relationship between `'a` and
9// `'b`. This relationship is propagated to the closure creator,
10// which reports an error.
11
923072b8 12// compile-flags:-Zverbose
ff7c6d11
XL
13
14#![feature(rustc_attrs)]
15
16#[rustc_regions]
17fn test() {
18 let x = 44;
19 let mut p = &x;
20
21 {
22 let y = 22;
23 let mut closure = || p = &y;
24 //~^ ERROR `y` does not live long enough [E0597]
25 closure();
26 }
27
28 deref(p);
29}
30
31fn deref(_p: &i32) { }
32
33fn main() { }