Simplify the HIR ty lowering of trait object lifetime bounds#157591
Open
fmease wants to merge 2 commits into
Open
Simplify the HIR ty lowering of trait object lifetime bounds#157591fmease wants to merge 2 commits into
fmease wants to merge 2 commits into
Conversation
Collaborator
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
r? me |
Letting `lower_lifetime` check `tcx.named_bound_var` & call `re_infer` just means we now end up passing `lifetime.ident.span` to `re_infer` instead of the `span` of the trait object type. However, 1. in the case of `LifetimeKind::ImplicitObjectLifetimeDefault` `lifetime.ident.span` is actually equal to said span. 2. in the case of `LifetimeKind::Infer` the span now makes more sense; consider `dyn Trait + '_` where the span now just contains the `'_` not the entire type which is just better.
c89555f to
6b234eb
Compare
…nfer` This makes it really obvious that we're computing object region bounds for `Infer`, too, not just for `ImplicitObjectLifetimeDefault` which was really hard to see beforehand. It's unclear to me whether this was intentional or not, needs investigation. Introduce method `lower_trait_object_lifetime` to allow usage of early returns to make the control flow clearer compared to the `unwrap_or_else`.
fmease
commented
Jun 8, 2026
Comment on lines
+456
to
+457
| // Curiously, we also use the *object region bound* for `Infer` (`'_`) | ||
| // while we obviously don't use the *object lifetime default* for it... |
Member
Author
There was a problem hiding this comment.
For a tiny bit more background information, see the large paragraph in the PR description of rust-lang/reference#2281 (the one about compute_object_lifetime_bound vs. RBV's named_bound_var).
Member
There was a problem hiding this comment.
Thanks for pointing this out, I'll take a closer look at this reference tomorrow
Kivooeo
approved these changes
Jun 9, 2026
Member
|
@bors r+ rollup |
Contributor
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.
See individual commit messages for details.