diff options
Diffstat (limited to 'src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs')
-rw-r--r-- | src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs new file mode 100644 index 000000000..bdd6cb79b --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.rs @@ -0,0 +1,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(); +} |