summaryrefslogtreecommitdiffstats
path: root/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs
blob: bdd6cb79b60b09f414508c21884102b06cace66d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// edition:2021

#[derive(Debug)]
struct Point {
    x: String,
    y: String,
}
fn main() {
    let mut c = {
        let mut p = Point {x: "1".to_string(), y: "2".to_string() };
        || {
           let x = &mut p.x;
           println!("{:?}", p);
            //~^ ERROR `p` does not live long enough
        }
    };
    c();
}