Treat vars created for opaque subtyping as live everywhere - #161151
Conversation
This comment has been minimized.
This comment has been minimized.
104159c to
be1ec41
Compare
|
Disclosure: An LLM was used to help diagnose the root cause of the issue |
This comment has been minimized.
This comment has been minimized.
be1ec41 to
b06c28a
Compare
There was a problem hiding this comment.
As discussed, I don't believe people will encounter this in practice, especially as this code will be unused in the next couple days when we enable the new solver on nightly, but it's fine to land it.
r=me with slight more focus on the regression test being old solver only, so we don't have to think much about what to do with it when we stabilize the new solver.
b06c28a to
16ae7a4
Compare
|
@bors r=lqd |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 8fa1c96 (parent) -> cda599c (this PR) Test differencesShow 11 test diffsStage 1
Stage 2
Additionally, 2 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard cda599c55f56d6cc234352f267102c293e55f3d0 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (cda599c): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.1%, secondary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 1.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 458.344s -> 455.4s (-0.64%) |
Fixes #160669
r? lqd
Let's look at a minimal variant of #160669
That has the following (simplified) MIR:
And the following region constraints:
Note
'?5and'?6: these don't show up in the MIR graph because they arise from theenable_subtypingclosure inrelate_opaques. Importantly (today), these regions are related to each other (and to other regions in hidden types) at a single point, but are not live at any point.For NLL this is not a problem (since liveness does not matter for outlives constraint propagation. For Polonius, this is an issue.
The fix here is fairly simple: consider these lifetimes live at all points. This may be an overestimate of liveness, but this is all code that doesn't get called with the next solver.
This is also the same reason that this is not an issue with the next solver. Opaque types are normalized in HIR typeck, so these hacky regions are never created.
There are a couple alternative fixes that I think are ultimately not as good:
Locations::All- when registering the goals from equating these two, forceLocations::Allinstead ofLocations::Single.insert_hidden_type, which then get equated with the "expected" hidden type inapply_definition_site_hidden_typeswithLocations::All. I think this is fine, but a lot less "local" logic.I'll note that for the next solver, we equate the hidden types with the return type in the signature with
Locations::Single:(note, this MIR is slightly different:
'5isshort's lifetime;'6is the lifetime from the normalized opaque (&'?6 ());'4is the renumbered lifetime for the MIR body)Given that, perhaps (1) is the most faithful to the spirit of the next solver (that there is one hidden type that things get related to), but this seems like a slightly smaller-in-scope fix.
In any case, I think any solution here is mostly just a waiting game for the next solver.