traits: Fix rigid alias liveness matching - #160212
Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I'm not sure this is correct. Or, at least, I'm not sure this is the right fix. It certainly isn't principled.
I don't have time to fully dig in right now, but generally I would not expect us to arbitrarily be setting things as rigid. I'm not sure the correct fix, but the may even be in the use or definition of extract_verify_if_eq (or may not be).
|
Yeah, that makes sense. I reworked this so liveness does not set aliases rigid anymore. The ICE was in the path you pointed at, or at least right next to it: So imo the better fix is to make btw I kept the liveness-side identity alias as |
|
We previously have a |
|
@adwinwhite can you review here? You're much more familiar with what might be the correct fix here than I am. |
|
r? me |
|
Thanks! Ping me if there's a question here for me or something otherwise needed from me! |
|
I think we shouldn't weaken the checks in The reasons we have non-rigid aliases here are
It's difficult to normalize here. So we have to live with a hack, hopefully less bad :/ |
|
☔ The latest upstream changes (presumably #160559) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
|
I would very much not like to land a hack here; I'd like to stay principled in this space, because the soundness around opaque type liveness involves accurately identifying regions that could be within an alias. This is a query because:
The only thing that I worry about is something like |
Fixes #160206
The ICE happens while borrowck computes liveness for an opaque return type with an associated type bound. In the repro, the opaque has a bound like
<impl Foo<'x> as Foo<'x>>::Out: 'static.live_args_for_alias_from_outlives_boundstries to use that bound to decide which opaque args may still be live, but it does that throughextract_verify_if_eq, which is just a syntactic matcher.With the next solver, aliases that cannot normalize further are represented as rigid. The type reaching liveness is already in that shape, but this query rebuilds the opaque identity alias as non-rigid and reads item bounds that can still contain non-rigid aliases. So the matcher gets two different representations of the same kind of alias and hits the debug assert before it can give the conservative answer.
This puts the identity alias and the outlives clauses into the next-solver alias form before matching. imo that is the right layer for this fix: liveness still does the cheap syntactic check it already did, and idk that adding normalization in borrowck liveness would be a good tradeoff here.