Description
At the top, the grammar is written as:
Syntax
TypeAlias :
type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? ( = Type WhereClause?)? ;
I assumed this applies to every instance of a type alias, but it's not. For example, type aliases are not allowed to have no type specified when declared as a top level item, but it is when as an associated type in a trait.
This is mentioned in the later paragraphs, however:
A type alias, when not used as an associated type, must include a Type and may not include TypeParamBounds.
A type alias, when used as an associated type in a trait, must not include a Type specification but may include TypeParamBounds.
A type alias, when used as an associated type in a trait impl, must include a Type specification and may not include TypeParamBounds.
This is confusing for me. I think it would be better if there was a syntax box like the one mentioned above for each case where a type alias can be found. So for example, these would be the syntax boxes for each:
Syntax
TypeAlias :
type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? = Type WhereClause? ;
Syntax
TypeAlias :
type IDENTIFIER GenericParams? : TypeParamBounds WhereClause? ;
Syntax
TypeAlias :
type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? = Type WhereClause? ;