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.
Point to span of upvar making closure FnMut
Add expected error Add comment Tweak comment wording Fix after rebase to updated master Fix after rebase to updated master Distinguish mutation in normal and move closures Tweak error message Fix error message for nested closures Refactor code showing mutated upvar in closure Remove debug assert B
- Loading branch information
1 parent
66eb982
commit 26b4baf
Showing
13 changed files
with
152 additions
and
4 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
7 changes: 7 additions & 0 deletions
7
src/test/ui/closures/issue-80313-mutable-borrow-in-closure.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,7 @@ | ||
fn main() { | ||
let mut my_var = false; | ||
let callback = || { | ||
&mut my_var; | ||
}; | ||
callback(); //~ ERROR E0596 | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/closures/issue-80313-mutable-borrow-in-closure.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,14 @@ | ||
error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-80313-mutable-borrow-in-closure.rs:6:5 | ||
| | ||
LL | let callback = || { | ||
| -------- help: consider changing this to be mutable: `mut callback` | ||
LL | &mut my_var; | ||
| ------ calling `callback` requires mutable binding due to mutable borrow of `my_var` | ||
LL | }; | ||
LL | callback(); | ||
| ^^^^^^^^ cannot borrow as mutable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0596`. |
7 changes: 7 additions & 0 deletions
7
src/test/ui/closures/issue-80313-mutable-borrow-in-move-closure.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,7 @@ | ||
fn main() { | ||
let mut my_var = false; | ||
let callback = move || { | ||
&mut my_var; | ||
}; | ||
callback(); //~ ERROR E0596 | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/closures/issue-80313-mutable-borrow-in-move-closure.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,14 @@ | ||
error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-80313-mutable-borrow-in-move-closure.rs:6:5 | ||
| | ||
LL | let callback = move || { | ||
| -------- help: consider changing this to be mutable: `mut callback` | ||
LL | &mut my_var; | ||
| ------ calling `callback` requires mutable binding due to possible mutation of `my_var` | ||
LL | }; | ||
LL | callback(); | ||
| ^^^^^^^^ cannot borrow as mutable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0596`. |
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,7 @@ | ||
fn main() { | ||
let mut my_var = false; | ||
let callback = || { | ||
my_var = true; | ||
}; | ||
callback(); //~ ERROR E0596 | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/closures/issue-80313-mutation-in-closure.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,14 @@ | ||
error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-80313-mutation-in-closure.rs:6:5 | ||
| | ||
LL | let callback = || { | ||
| -------- help: consider changing this to be mutable: `mut callback` | ||
LL | my_var = true; | ||
| ------ calling `callback` requires mutable binding due to mutable borrow of `my_var` | ||
LL | }; | ||
LL | callback(); | ||
| ^^^^^^^^ cannot borrow as mutable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0596`. |
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,7 @@ | ||
fn main() { | ||
let mut my_var = false; | ||
let callback = move || { | ||
my_var = true; | ||
}; | ||
callback(); //~ ERROR E0596 | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/closures/issue-80313-mutation-in-move-closure.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,14 @@ | ||
error[E0596]: cannot borrow `callback` as mutable, as it is not declared as mutable | ||
--> $DIR/issue-80313-mutation-in-move-closure.rs:6:5 | ||
| | ||
LL | let callback = move || { | ||
| -------- help: consider changing this to be mutable: `mut callback` | ||
LL | my_var = true; | ||
| ------ calling `callback` requires mutable binding due to possible mutation of `my_var` | ||
LL | }; | ||
LL | callback(); | ||
| ^^^^^^^^ cannot borrow as mutable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0596`. |
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