fix: flatten nested HRTB predicate binders - #23139
Open
YUZHEthefool wants to merge 1 commit into
Open
Conversation
dfireBird
reviewed
Aug 15, 2026
YUZHEthefool
force-pushed
the
fix/nested-hrtb-predicate-binders
branch
from
August 16, 2026 06:23
8796ae2 to
d0a84a4
Compare
Contributor
Author
|
Now, lifetime search is changed to preferentially match the last name added in the same binder, correctly handle nested lifetime shadowing, and remove the previously incorrect index offset. |
ChayimFriedman2
requested changes
Aug 27, 2026
| if let LifetimeRef::Named(lt_name) = &self.store[lifetime] { | ||
| self.bound_vars.iter().rev().enumerate().find_map(|(debruijn, (binder, _))| { | ||
| binder.iter().enumerate().find_map(|(index, l)| { | ||
| binder.iter().enumerate().rev().find_map(|(index, l)| { |
Contributor
There was a problem hiding this comment.
Why this rev()?
YUZHEthefool
force-pushed
the
fix/nested-hrtb-predicate-binders
branch
from
August 28, 2026 12:55
d0a84a4 to
62b2fa4
Compare
This comment has been minimized.
This comment has been minimized.
YUZHEthefool
force-pushed
the
fix/nested-hrtb-predicate-binders
branch
from
August 28, 2026 13:07
62b2fa4 to
98e4292
Compare
Collaborator
|
This PR was rebased onto a different master 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
两个issue的问题都在于关联类型 bound 递归 lowering 时,clause binder 只记录最内层 lifetime,引用的外层 lifetime 以 ^1/^2 形式逃逸。因此我修复了lower.rs中将 overarching 和内层 HRTB 变量合并到同一个 predicate binder,同时保留dyn Trait了作为真正独立的existential binder。
<The problem is that when the associated type bound is recursively lowering, the clause binder only records the innermost lifetime, and the outer lifetime of the reference escapes in the form of ^1/^2.
So I fix merging overarching and inner HRTB variables into the same predicate binder in lower.rs while retaining the dyn Trait's truly independent existential binder.>
In simpler terms: Outer lifetimes in nested binders are not flattened/renumbered correctly
Fix: #23063 and Fix #23064