diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/unboxed-closures/unboxed-closure-region.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/unboxed-closures/unboxed-closure-region.rs b/tests/ui/unboxed-closures/unboxed-closure-region.rs new file mode 100644 index 000000000..51fe118c9 --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closure-region.rs @@ -0,0 +1,11 @@ +// Test that an unboxed closure that captures a free variable by +// reference cannot escape the region of that variable. + + +fn main() { + let _f = { + let x = 0; + || x //~ ERROR closure may outlive the current block, but it borrows `x` + }; + _f; +} |