rust/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs

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

15 lines
265 B
Rust
Raw Normal View History

2020-02-14 16:39:55 -06:00
#![feature(unboxed_closures)]
// Tests that we can't assign to or mutably borrow upvars from `Fn`
// closures (issue #17780)
fn main() {}
fn bar() -> impl Fn() -> usize {
let mut x = 0;
move || {
x += 1; //~ ERROR cannot assign
x
}
}