forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edddb62
commit d863978
Showing
7 changed files
with
82 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/borrowck/borrow-immutable-upvar-mutation-impl-trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure | ||
--> $DIR/borrow-immutable-upvar-mutation-impl-trait.rs:11:9 | ||
| | ||
LL | fn bar() -> impl Fn() -> usize { | ||
| --- ------------------ change this to return `FnMut` instead of `Fn` | ||
LL | let mut x = 0; | ||
LL | / move || { | ||
LL | | x += 1; | ||
| | ^^^^^^ cannot assign | ||
LL | | x | ||
LL | | } | ||
| |_____- in this closure | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0594`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters