-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] Rework how type params are parsed #61254
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
I need to improve the wording, and it'd be a good idea to keep the separation in the hir as well, but the bulk of work is done. |
| | ||
LL | let _: S<'static +, 'static>; | ||
| ^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^ help: reorder the arguments: `'static, 'static` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires fixing before merging.
This comment has been minimized.
This comment has been minimized.
Separate lifetimes, type arguments, const params and type bindings as early as possible in the parser. When encountering bad ordering, suggest the correct order in a homogeneous way for all possible incorrect ordering.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
pub args: Vec<GenericArg>, | ||
pub lifetimes: Vec<Lifetime>, | ||
pub types: Vec<P<Ty>>, | ||
pub const_args: Vec<AnonConst>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are you going to preserve the correct order? Types and constants can be interleaved, last I checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(They're currently blocked from being so, but this restriction was not necessarily intended to be permanent.)
I don't see the point of this revert - how does it help diagnostics at all? |
It looks like this regresses diagnostics too? |
I'll rework the approach. I'm still not sure I understand the benefit of having lifetimes share the same vec as type args and const args, while we do separate bindings, but evidently it is something I'm not seeing.
This was a first pass to try and unify the "incorrectly ordered args" in one place, the second pass would have been wording/polish. I first started only doing the diagnostic part and realized that there are multiple places where we didn't care about most of the arg vec, we either only cared about lifetimes or type params. It ballooned into this PR.
Point taken, although that doesn't preclude separating lifetimes away :)
I wasn't aware of that PR, but the spirit behind this is the same as the one expressed in #45930 (comment). @eddyb advised making the parser agnostic and making these checks only later in typeck. I'll look into it in a separate PR. |
Separate lifetimes, type arguments, const params and type bindings
as early as possible in the parser. When encountering bad ordering,
suggest the correct order in a homogeneous way for all possible
incorrect ordering.