rust/tests/ui/borrowck/issue-45983.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
326 B
Rust
Raw Normal View History

// As documented in Issue #45983, this test is evaluating the quality
// of our diagnostics on erroneous code using higher-ranked closures.
fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) {
f(&());
}
fn main() {
2020-05-20 17:58:41 +00:00
let mut x = None;
give_any(|y| x = Some(y));
2020-05-20 17:58:41 +00:00
//~^ ERROR borrowed data escapes outside of closure
}