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 :/ |
This comment has been minimized.
This comment has been minimized.
|
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 |
|
Wassup, ty both for your time invested! Two things I hit while working through @adwinwhite's plan that I want to confirm first, because I don't think it and @jackh726's "no hack" constraint fully agree yet. The filtering I'll just do. The clause that ICEs comes from Question 1: making Question 2: the assert in The alternative I'd rather write: everything the query and imo the index version is worth the churn even though it's the bigger diff. Every time we launder rigidness through an One more, @jackh726, on |
a9ef45e to
5c1eddb
Compare
This comment has been minimized.
This comment has been minimized.
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
|
@lcnr update: I pulled the bitset work out into #160936 so this PR stays focused on the behavioral / Zulip context still applies: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/rigid.20aliases.20in.20region.20handling/near/615557841 imo the bitset was the right first step, but mixing it here made the review surface noisier than it needed to be. the open question on this PR is still the matcher: do we need proper matching/normalization in fyi I left the ignore-rigidness matcher commit here for now. lmk if you'd rather I drop it / swap to the exact- |
This comment has been minimized.
This comment has been minimized.
|
can you split out the bitset change from the behaviorial changes in this PR? ideally open a separate PR for just the bitset change |
Ofc! |
3d4d472 to
db4cb2b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@lcnr split's done. Bitset landed in #160936. This PR is back to just the behavioral / imo that's cleaner for review. the bitset is pure churn on query shape, and mixing it with the ICE fix was making the diff harder to reason about than it needed to be. lmk if you'd rather I stack #160212 on top of that one instead of keeping them independent. |
View all comments
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.