Skip to content

parser: Ensure that all nonterminals have tokens after parsing#84995

Merged
bors merged 1 commit intorust-lang:masterfrom
petrochenkov:tcollect
Jun 6, 2021
Merged

parser: Ensure that all nonterminals have tokens after parsing#84995
bors merged 1 commit intorust-lang:masterfrom
petrochenkov:tcollect

Conversation

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented May 6, 2021

parse_nonterminal should always result in something with tokens.

This requirement wasn't satisfied in two cases:

  • stmt nonterminal with expression statements (e.g. 0, or {}, or path + 1) because fn parse_stmt_without_recovery forgot to propagate force_collect in some cases.
  • expr nonterminal with expressions with built-in attributes (e.g. #[allow(warnings)] 0) due to an incorrect optimization in fn parse_expr_force_collect, it assumed that all expressions starting with # have their tokens collected during parsing, but that's not true if all the attributes on that expression are built-in and inert.

(Discovered when trying to implement eager cfg expansion for all attributes #83824 (comment).)

r? @Aaron1011

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants