Rollup of 8 pull requests by Centril · Pull Request #69919 · rust-lang/rust (original) (raw)

Improve expression & attribute parsing

This PR includes misc improvements to expression and attribute parsing.

  1. Some code simplifications
  2. Better recovery for various block forms, e.g. loop statements } (missing { after loop). (See e.g., block-no-opening-brace.rs among others for examples.)
  3. Added recovery for e.g., unsafe <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>b</mi><mi mathvariant="normal">‘</mi><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">b where </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span><span class="mord">‘</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mord">‘</span></span></span></span>b refers to a block macro fragment. (See bad-interpolated-block.rs for examples.)
  4. ^--- These are done so that code sharing in block parsing is increased.
  5. Added recovery for e.g., 'label: loop { ... } (See labeled-no-colon-expr.rs.)
  6. Added recovery for e.g., &'lifetime expr (See regions-out-of-scope-slice.rs.)
  7. Added recovery for e.g., fn foo() = expr; (See fn-body-eq-expr-semi.rs.)
  8. Simplified attribute parsing code & slightly improved diagnostics.
  9. Added recovery for e.g., Box<('a) + Trait>.
  10. Added recovery for e.g, if true #[attr] {} else #[attr] {} else #[attr] if true {}.

r? @estebank