]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/closure-requirements/escape-upvar-ref.rs
49d31bbc139d73f0b88aca1551900018681a7e6c
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 // - captures a variable `y` by reference
14 // - stores that reference to `y` into another, longer-lived place (`p`)
16 // Both of these are upvars of reference type (the capture of `y` is
17 // of type `&'a i32`, the capture of `p` is of type `&mut &'b
18 // i32`). The closure thus computes a relationship between `'a` and
19 // `'b`. This relationship is propagated to the closure creator,
20 // which reports an error.
22 // compile-flags:-Zborrowck=mir -Zverbose
24 #![feature(rustc_attrs)]
33 let mut closure
= || p
= &y
;
34 //~^ ERROR `y` does not live long enough [E0597]
41 fn deref(_p
: &i32) { }