-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add richer structure for Stable MIR Projections #117517
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
r? @celinval |
Failed to set assignee to
|
@klinvill I'm not an official reviewer, I'll take a look at it though. r? @spastorino can you take a look at it please? |
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.
I would like to suggest that you crate a new test instead of extending the existing one. Thanks for doing this though!
compiler/stable_mir/src/mir/body.rs
Outdated
pub projection: Vec<ProjectionElem<Local, Ty>>, | ||
} | ||
|
||
// TODO(klinvill): in MIR ProjectionElem is parameterized on the second Field argument and the Index |
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.
I don't have a strong opinion here since I haven't used UserTypeProjection
. That said, if not all elements are valid for UserTypeProjection, I would probably keep them separate.
This commit includes richer projections for both Places and UserTypeProjections. However, the tests only touch on Places. There are also outstanding TODOs regarding how projections should be resolved to produce Place types, and regarding if UserTypeProjections should just contain ProjectionElem<(),()> objects as in MIR.
Asserting is_empty is slightly more concise.
It's not clear to me (klinvill) that UserTypeProjections are produced anymore with the removal of type ascriptions as per rust-lang/rfcs#3307. Furthermore, it's not clear to me which variants of ProjectionElem could appear in such projections. For these reasons, I'm reverting projections in UserTypeProjections to simple strings until I can get more clarity on UserTypeProjections.
3270247
to
d517a1c
Compare
This comment has been minimized.
This comment has been minimized.
This PR changes Stable MIR cc @oli-obk, @celinval, @spastorino, @ouz-a |
This comment has been minimized.
This comment has been minimized.
@spastorino I'm ready for a review on this PR. A few notable decisions/outstanding questions are:
@celinval I also added a visitor for |
I will try to address these.
|
r? @celinval @spastorino I'll take this one. |
Thanks for the suggestions @ouz-a and @celinval. The inconsistency of having I'd advocate for having that information accessible through a lookup based on the index rather than passing around additional information (which would potentially need to be updated as Variants and Fields evolve). However, such a lookup is currently neither possible (due to So I suppose this is my long-winded way of proposing to drop the |
Sounds reasonable to me. Can you please capture your comment above into an issue in project-stable-mir? We should revisit this in the near term, and create a follow up PR. Thank you |
This is probably nothing |
💡 This pull request was already approved, no need to approve it again.
|
Add richer structure for Stable MIR Projections Resolves rust-lang/project-stable-mir#49. Projections in Stable MIR are currently just strings. This PR replaces that representation with a richer structure, namely projections become vectors of `ProjectionElem`s, just as in MIR. The `ProjectionElem` enum is heavily based off of the MIR `ProjectionElem`. This PR is a draft since there are several outstanding issues to resolve, including: - How should `UserTypeProjection`s be represented in Stable MIR? In MIR, the projections are just a vector of `ProjectionElem<(),()>`, meaning `ProjectionElem`s that don't have Local or Type arguments (for `Index`, `Field`, etc. objects). Should `UserTypeProjection`s be represented this way in Stable MIR as well? Or is there a more user-friendly representation that wouldn't drag along all the `ProjectionElem` variants that presumably can't appear? - What is the expected behavior of a `Place`'s `ty` function? Should it resolve down the chain of projections so that something like `*_1.f` would return the type referenced by field `f`? - Tests should be added for `UserTypeProjection`
Maybe we should re-try this again before rolling it up |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (698fcc8): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 674.399s -> 674.6s (0.03%) |
Add VarDebugInfo to Stable MIR Previously we omitted `VarDebugInfo` because we didn't have `Projection` now that rust-lang#117517 is merged it's possible to add `VarDebugInfo` information in `Body`. This PR adds stable version of the `VarDebugInfo` to `Body` r? `@celinval`
Add VarDebugInfo to Stable MIR Previously we omitted `VarDebugInfo` because we didn't have `Projection` now that rust-lang#117517 is merged it's possible to add `VarDebugInfo` information in `Body`. This PR adds stable version of the `VarDebugInfo` to `Body` r? `@celinval`
Add VarDebugInfo to Stable MIR Previously we omitted `VarDebugInfo` because we didn't have `Projection` now that rust-lang#117517 is merged it's possible to add `VarDebugInfo` information in `Body`. This PR adds stable version of the `VarDebugInfo` to `Body` r? ``@celinval``
Add VarDebugInfo to Stable MIR Previously we omitted `VarDebugInfo` because we didn't have `Projection` now that rust-lang#117517 is merged it's possible to add `VarDebugInfo` information in `Body`. This PR adds stable version of the `VarDebugInfo` to `Body` r? ```@celinval```
Rollup merge of rust-lang#117972 - ouz-a:stable_debuginfo, r=celinval Add VarDebugInfo to Stable MIR Previously we omitted `VarDebugInfo` because we didn't have `Projection` now that rust-lang#117517 is merged it's possible to add `VarDebugInfo` information in `Body`. This PR adds stable version of the `VarDebugInfo` to `Body` r? ```@celinval```
Resolves rust-lang/project-stable-mir#49.
Projections in Stable MIR are currently just strings. This PR replaces that representation with a richer structure, namely projections become vectors of
ProjectionElem
s, just as in MIR. TheProjectionElem
enum is heavily based off of the MIRProjectionElem
.This PR is a draft since there are several outstanding issues to resolve, including:
UserTypeProjection
s be represented in Stable MIR? In MIR, the projections are just a vector ofProjectionElem<(),()>
, meaningProjectionElem
s that don't have Local or Type arguments (forIndex
,Field
, etc. objects). ShouldUserTypeProjection
s be represented this way in Stable MIR as well? Or is there a more user-friendly representation that wouldn't drag along all theProjectionElem
variants that presumably can't appear?Place
'sty
function? Should it resolve down the chain of projections so that something like*_1.f
would return the type referenced by fieldf
?UserTypeProjection