-
Notifications
You must be signed in to change notification settings - Fork 0
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
Move capture lowering from THIR to MIR #30
Conversation
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.
Some nits but otherwise lgtm
// Access the capture by accessing the field within the Closure struct. | ||
// | ||
// We must have inferred the capture types since we are build MIR, therefore | ||
// it's safe to call `upvar_tys` and we know can unwrap here because |
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.
now
|
||
// Access the capture by accessing the field within the Closure struct. | ||
// | ||
// We must have inferred the capture types since we are build MIR, therefore |
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.
building
This allows us to: - Handle precise Places captured by a closure directly in MIR. Handling captures in MIR is easier since we can rely on/ tweak PlaceBuilder to generate `mir::Place`s that resemble how we store captures (`hir::Place`). - Allows us to handle `let _ = x` case when feature `capture_disjoint_fields` is enabled directly in MIR. This is required to be done in MIR since patterns are desugared in MIR.
ExprKind::SelfRef was used to express accessing `self` in the desugared Closure/Generator struct when lowering captures in THIR. Since we handle captures in MIR now, we don't need `ExprKind::Self`.
32009e2
to
9f70e78
Compare
Fixed and created rust-lang PR here: rust-lang#79149 |
This allows us to:
Handle precise Places captured by a closure directly in MIR. Handling
captures in MIR is easier since we can rely on/ tweak PlaceBuilder to
generate
mir::Place
s that resemble how we store captures (hir::Place
).Handle
let _ = x
case when featurecapture_disjoint_fields
is enabled directly in MIR. This is required to be done in MIR since
patterns are desugared in MIR.
Closes: rust-lang/project-rfc-2229#25
This change is