feat: early late classification of lifetimes#22283
Conversation
This comment has been minimized.
This comment has been minimized.
f164e84 to
7febdbd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
91d006d to
1686871
Compare
This comment has been minimized.
This comment has been minimized.
8f91999 to
7a9b149
Compare
This comment has been minimized.
This comment has been minimized.
| #[derive(Clone, PartialEq, Eq, Debug, Hash)] | ||
| pub struct LifetimeParamData { | ||
| pub name: Name, | ||
| pub bound_type: LifetimeBoundType, |
There was a problem hiding this comment.
I wonder if we should have different arenas for the early and late bound lifetimes, so locating a lifetime param's index can be O(1).
There was a problem hiding this comment.
Coming to this (I kept this to the last), we can't do that with what we have. Since we don't know if lifetime is late bound or early bound until after we finish our hir-def lowering. We can not mutate the arena itself that will make the Idx of that arena to be invalidated.
There was a problem hiding this comment.
True, but we don't need the Idx during lowering. We can just make the arenas after we finish lowering.
There was a problem hiding this comment.
If that's the case, I'll try doing something.
There was a problem hiding this comment.
It was fairly simple to get it to compile without errors, the only thing I find problematic is implementation of std::ops::Idx<LocalLifetimeParamId>, which lifetime arena to choose? We are currently (with my changes ofc) indexing with both early and late lifetimes.
There was a problem hiding this comment.
They need to have a different ID, otherwise many things will be problematic.
There was a problem hiding this comment.
I feel like that's unnecessary complexity for an optimization that would only benefit two methods, the new lifetime_param_idx and len_late_bound_lifetimes. Both for which can be handled through pre-computing and storing those value.
There was a problem hiding this comment.
I didn't say we should do this, I was only wondering whether it's better. But do note that these methods may be fairly hot.
There was a problem hiding this comment.
Yeah I get it.
I was just voicing out my thoughts 😅 .
b2f078f to
3c22245
Compare
|
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. |
3c22245 to
963cf62
Compare
Some things to note:
in_bindersand fully replace it withbound_varsstack.FIXMEin ide tests)