Rework the syntax specification

For the formal syntax, we had used the existing `GenericParams`
production.  However, that production isn't exactly appropriate for
this case.  What's needed here is essentially a generic argument list
that only accepts generic parameters as elements.

Since none of the other existing productions provide this, we'll
define our own.

(Thanks to @kennytm for pointing this out.)
This commit is contained in:
Travis Cross 2024-04-24 21:48:15 +00:00
parent 585458cc82
commit dc8f93d315
1 changed files with 17 additions and 5 deletions

View File

@ -171,18 +171,30 @@ The [syntax for `impl Trait`][] is revised and extended as follows:
[syntax for `impl Trait`]: https://doc.rust-lang.org/nightly/reference/types/impl-trait.html
> _UseCaptures_ :\
>    `use` [_GenericParams_][]
>
> _ImplTraitType_ :
> &nbsp;&nbsp; `impl` _UseCaptures_<sup>?</sup> [_TypeParamBounds_][]
>
> _ImplTraitTypeOneBound_ :
> &nbsp;&nbsp; `impl` _UseCaptures_<sup>?</sup> [_TraitBound_][]
>
> _UseCaptures_ :\
> &nbsp;&nbsp; `use` _UseCapturesGenericArgs_
>
> _UseCapturesGenericArgs_ :\
> &nbsp;&nbsp; &nbsp;&nbsp; `<` `>` \
> &nbsp;&nbsp; | `<` \
> &nbsp;&nbsp; &nbsp;&nbsp; ( _UseCapturesGenericArg_ `,`)<sup>\*</sup> \
> &nbsp;&nbsp; &nbsp;&nbsp; _UseCapturesGenericArg_ `,`<sup>?</sup> \
> &nbsp;&nbsp; &nbsp;&nbsp; `>`
>
> _UseCapturesGenericArg_ :\
> &nbsp;&nbsp; &nbsp;&nbsp; [LIFETIME_OR_LABEL][] \
> &nbsp;&nbsp; | [IDENTIFIER][]
[_GenericParams_]: https://doc.rust-lang.org/nightly/reference/items/generics.html
[_TypeParamBounds_]: https://doc.rust-lang.org/nightly/reference/trait-bounds.html
[IDENTIFIER]: https://doc.rust-lang.org/nightly/reference/identifiers.html
[LIFETIME_OR_LABEL]: https://doc.rust-lang.org/nightly/reference/tokens.html#lifetimes-and-loop-labels
[_TraitBound_]: https://doc.rust-lang.org/nightly/reference/trait-bounds.html
[_TypeParamBounds_]: https://doc.rust-lang.org/nightly/reference/trait-bounds.html
## Reference desugaring