-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
2229: Fix issues with move closures and mutability #80092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b421cd5
Restrict precision of captures with `capture_disjoint_fields` set
arora-aman 3488082
Compute mutability of closure captures
arora-aman 1373f98
Test cases for handling mutable references
arora-aman 0897db5
Test for restricting capture precision
arora-aman 604cbdc
Fix unused 'mut' warning for capture's root variable
arora-aman c748f32
Fix incorrect use mut diagnostics
arora-aman ffd5327
Add fixme for precise path diagnostics
arora-aman fadf03e
Fix typos
arora-aman 0f4bab2
Fixme for closure origin when reborrow is implemented
arora-aman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix unused 'mut' warning for capture's root variable
- Loading branch information
commit 604cbdcfddb959cd1d7de2f9afa14a199561a428
There are no files selected for viewing
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1369,13 +1369,38 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { | |||||
|
|
||||||
| fn propagate_closure_used_mut_upvar(&mut self, operand: &Operand<'tcx>) { | ||||||
| let propagate_closure_used_mut_place = |this: &mut Self, place: Place<'tcx>| { | ||||||
| if !place.projection.is_empty() { | ||||||
| if let Some(field) = this.is_upvar_field_projection(place.as_ref()) { | ||||||
| // We have three possiblities here: | ||||||
| // a. We are modifying something through a mut-ref | ||||||
| // b. We are modifying something that is local to our parent | ||||||
| // c. Current body is a nested clsoure, and we are modifying path starting from | ||||||
|
||||||
| // c. Current body is a nested clsoure, and we are modifying path starting from | |
| // c. Current body is a nested closure, and we are modifying a path starting from |
Outdated
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To handle the deref of &mut` case, we could check here if
- the projection is a deref
- the type of the
place_refis an&mut
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.