mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
* `can_continue_expr_unambiguously`
* exhaustively match on `AssocOp`
* don't needlessly provide code snippets in comments for ops that are
unproblematic, that's not interesting
* instead, provide an example / explainer for each op that is ambiguous
which is far more relevant
* move it into `rustc_parse` since it's only used there & it's only
tailored towards parse error recovery
* `should_continue_as_assoc_expr`
* it used to match on a `(bool, _)` tuple & execute `AssocOp::from_token`
unconditionally even though all but one branch cared about the bool
being false
* instead, first check `expr_is_complete` and bail out early if it's
false; no need to execute `AssocOp::from_token` unnecessarily or
"bother" the rest of the code with the impossibility of
`expr_is_complete` not holding
* extract the recovery logic into a new
`recover_from_bin_op_after_complete_stmt_expr` that resides in
`expr/diagnostics.rs` to clearly separate what is recovery and what
is actual parsing
* in it check `can_continue_expr_unambiguously` *first* before
special-casing some ops (the `Mul | Sub | …` branch) because it's
more "important"; in any case it's a superset; renders the control
flow & the logic a lot more comprehensible
* rewrite the comments from scratch to make it clear that all of that
"bin op after complete stmt expr" is recovery code only! when I
first came across this function one year ago I was super confused &
briefly worried that typeck was potentially making belated parsing
decisions
* inline it because it's become a single expression
The rustc_ast crate contains those things concerned purely with syntax
– that is, the AST ("abstract syntax tree"), along with some definitions for tokens and token streams, data structures/traits for mutating ASTs, and shared definitions for other AST-related parts of the compiler (like the lexer and macro-expansion).
For more information about how these things work in rustc, see the rustc dev guide: