diff options
Diffstat (limited to 'tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs')
-rw-r--r-- | tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs b/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs new file mode 100644 index 000000000..57198cb95 --- /dev/null +++ b/tests/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs @@ -0,0 +1,14 @@ +#![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 + } +} |