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.
- Some code simplifications
- Better recovery for various block forms, e.g.
loop statements }
(missing{
afterloop
). (See e.g.,block-no-opening-brace.rs
among others for examples.) - 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 ablock
macro fragment. (Seebad-interpolated-block.rs
for examples.) - ^--- These are done so that code sharing in block parsing is increased.
- Added recovery for e.g.,
'label: loop { ... }
(Seelabeled-no-colon-expr.rs
.) - Added recovery for e.g.,
&'lifetime expr
(Seeregions-out-of-scope-slice.rs
.) - Added recovery for e.g.,
fn foo() = expr;
(Seefn-body-eq-expr-semi.rs
.) - Simplified attribute parsing code & slightly improved diagnostics.
- Added recovery for e.g.,
Box<('a) + Trait>
. - Added recovery for e.g,
if true #[attr] {} else #[attr] {} else #[attr] if true {}
.
r? @estebank