Resolve anon const's parent predicates to direct parent instead of opaque's parent #125501
+71
−97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When an anon const is inside of an opaque, #99801 added a hack to resolve the anon const's parent predicates not to the opaque's predicates, but to the opaque's parent's predicates. This is insufficient when considering nested opaques.
This means that the
predicates_of
an anon const might reference duplicated lifetimes (installed bycompute_bidirectional_outlives_predicates
) when computing known outlives in MIR borrowck, leading to these ICEs:Fixes #121574
Fixes #118403
Instead, we should be using theOpaqueTypeOrigin
to acquire the owner item (fn/type alias/etc) of the opaque, whose predicates we're fine to mention.I think it's a bit sketchy that we're doing this at all, tbh; I think it should be fine for the anon const to inherit the predicates of the opaque it's located inside. However, that would also mean that we need to make sure thegenerics_of
that anon const line up in the same way.None of this is important to solve right now; I just want to fix these ICEs so we can land #125468, which accidentally fixes these issues in a different and unrelated way.edit: We don't need this special case anyways because we install the right parent item in
generics_of
anyways:rust/compiler/rustc_hir_analysis/src/collect/generics_of.rs
Line 150 in 213ad10
r? @BoxyUwU