Closed
Description
Summary:
Parsing value as Type[index]
leads to the error:
expected one of `!`, `(`, `::`, `;`, or `<`, found `[`
It is currently impossible for a cast expression to have a trailing index expression without surrounding the cast expression by parenthesis. This however seems to be a parser limitation, not a grammar limitation.
As currently the macro language guarantees that ty/path expressions can be followed by a "[", this seems like a bug in the parser to me, as it seems to be parsing it as value as (Type[index])
which makes no grammatical sense, compared to parsing it as (value as Type)[index] which should be valid if I read the lexical structure specification correctly.
rustc --version
>>> rustc 1.12.0-nightly (576f76659 2016-08-09)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTCategory: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.