Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Rewrite HIR->MIR lowering to use Places #10

Closed
arora-aman opened this issue Jun 12, 2020 · 2 comments · Fixed by rust-lang/rust#79553
Closed

Rewrite HIR->MIR lowering to use Places #10

arora-aman opened this issue Jun 12, 2020 · 2 comments · Fixed by rust-lang/rust#79553
Assignees
Projects

Comments

@arora-aman
Copy link
Member

arora-aman commented Jun 12, 2020

No description provided.

@arora-aman arora-aman added this to To-do in RFC-2229 via automation Jun 12, 2020
@nikomatsakis
Copy link
Contributor

An idea for how we might approach this (but not the only one)

let c = || use(foo.bar.baz, foo.bar.baz2);

This results in a HIR like:

  • use()
    • field:baz // today: self.0.bar.baz
      • field:bar // today: self.0.bar
        • variable:foo // today returns a place like self.0

under new system:

  • when we reach foo, we would look up in the map and get a set of minimum captured places
  • the variable:foo nodes must appear as a child of some subtree that is in that set
  • whereas today MIR construction returns (HIR node -> MIR place)
    • it would return (HIR node -> (MIR place | {upvar captures})
  • the field:bar node would get back a set of captures that is not a singleton set, narrow it down, and return it up
  • the field:baz node would return the MIR place self.0

@arora-aman
Copy link
Member Author

@arora-aman arora-aman moved this from To-do to In progress in RFC-2229 Nov 19, 2020
@arora-aman arora-aman moved this from In progress to In review in RFC-2229 Dec 2, 2020
@arora-aman arora-aman self-assigned this Dec 7, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 12, 2020
…nikomatsakis

Capture precise paths in THIR and MIR

This PR allows THIR and MIR to use the result of the new capture analysis to actually capture precise paths

To achieve we:
- Writeback min capture results to TypeckResults
- Move handling upvars to PlaceBuilder in mir_build
- Lower precise paths in THIR build by reading min_captures
- Search for ancestors in min_capture when trying to build a MIR place which starts off of an upvar

Closes: rust-lang/project-rfc-2229#10

Partly implements: rust-lang/project-rfc-2229#18

Work that remains (not in this PR):
- [ ] [Known bugs when feature gate is enabled](https://github.com/rust-lang/project-rfc-2229/projects/1?card_filter_query=label%3Abug)
- [ ] Use min_capure_map for
  - [ ] Liveness analysis
  - [ ] rustc_mir/interpret/validity.rs
  - [ ] regionck
- [ ] rust-lang/project-rfc-2229#8
- [ ] remove closure_captures and upvar_capture_map

r? `@ghost`
RFC-2229 automation moved this from In review to Done Dec 12, 2020
@nikomatsakis nikomatsakis added this to the Feature complete milestone Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
RFC-2229
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants