]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closure-region.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / unboxed-closures / unboxed-closure-region.rs
1 // Test that an unboxed closure that captures a free variable by
2 // reference cannot escape the region of that variable.
3
4
5 fn main() {
6     let _f = {
7         let x = 0;
8         || x //~ ERROR closure may outlive the current block, but it borrows `x`
9     };
10     _f;
11 }