Fix the grammar of const param defaults by reusing rule for const args#2270
Fix the grammar of const param defaults by reusing rule for const args#2270fmease wants to merge 1 commit into
Conversation
| Lifetime | Type | ConstArg | GenericArgsBinding | GenericArgsBounds | ||
| GenericArgsConst -> | ||
| ConstArg -> |
There was a problem hiding this comment.
const arg / constant argument is the term we use in rustc (internally and in diagnostics).
Moreover, in rustc's parser, const arg doesn't just refer to const arguments literally but also to const param defaults (and to the RHS of associated const bindings as in TraitRef<CT = { 1 + 1 }> but that's unstable syntax). So "reusing" ConstArg in rule ConstParam doesn't come out of thin air.
`struct T<const N: U = crate>;` is syntactically valid but the previous definition of rule *ConstParam* didn't capture that fact since it listed *IDENTIFIER* while it needed to be *SimplePathSegment*.
|
I found an issue: The "const arg" used for the param default should include Edit: Well, as a matter of fact, GenericArgsConst already conflicts with Type on master ... I think remember a Zulip or GH discussion where ehuss (?) stated that it's still unclear how we want to represent identifier const args that can refer to either type or const in the grammar. |
struct T<const N: U = crate>;is syntactically valid but the previous definition of rule ConstParam didn't capture that fact since it only listed IDENTIFIER while it needed to be SimplePathSegment.