fix: track init and move in borrowck#372
Open
acegikmoo wants to merge 2 commits into
Open
Conversation
Signed-off-by: acegikmoo <rubairakib11@gmail.com>
Collaborator
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (NB. this repo may be misconfigured) some time within the next two weeks. |
Author
|
r? nikomatsakis |
tiif
reviewed
Jun 2, 2026
Comment on lines
+230
to
+241
| pub fn with_initialized(&self, place: &PlaceExpr) -> Self { | ||
| let mut this = self.clone(); | ||
| this.current.mark_initialized(place); | ||
| this | ||
| } | ||
|
|
||
| pub fn with_uninit(&self, place: &PlaceExpr) -> Self { | ||
| let mut this = self.clone(); | ||
| this.current.mark_uninit(place); | ||
| this | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
would it be better if we just call this.current.mark_initializeddirectly at the call site?
Author
There was a problem hiding this comment.
maybe, idk, i think as they follow the same pattern as with_loan, with_outlives, with_break, etc its bit consistent to the codebase. Also its not costing us anything either way.
if you still prefer it, it's pretty straightforward ig and i can take the stab
Signed-off-by: acegikmoo <rubairakib11@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
This pr is the implementation of approach-1 in the zulip chat, similar what we do in the compiler. This adds a
Set<PlaceExpr>to the flow state that tracks which places are uninitialized. It's a forward analysis in terms of approach-2(liveness) and it uses union at joins.related issue #296
How does it work, what questions do you have?
Tracks
Set<PlaceExpr>of uninitialized places inPointFlowState.uninit. Union at control-flow joins.On access:
check_place_initializedfails if any prefix or sub-path is in the set.On assignment:
check_place_writablefails if a strict prefix is in the set, then marks LHS initialized.On move: marks the place
uninit.On no init: marks
uninit.Questions:
move_in_loopstill ignored- some direction on handling that would be appreciatedAI disclosure