about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-08 17:26:17 +0000
committerbors <bors@rust-lang.org>2021-09-08 17:26:17 +0000
commit47ae8deb8a35030bdc4e502b03400800864cc264 (patch)
treed54ceba095ccad99db82466854201635442cea25 /compiler/rustc_parse/src/parser
parentc9db3e0fbc84d8409285698486375f080d361ef3 (diff)
parent4cb751e1f4ea6b9925e9be8984851f01d0003e30 (diff)
downloadrust-47ae8deb8a35030bdc4e502b03400800864cc264.tar.gz
rust-47ae8deb8a35030bdc4e502b03400800864cc264.zip
Auto merge of #88750 - jackh726:rollup-w57i9fp, r=jackh726
Rollup of 9 pull requests

Successful merges:

 - #86263 (Rustdoc: Report Layout of enum variants)
 - #88541 (Add regression test for #74400)
 - #88553 (Improve diagnostics for unary plus operators (#88276))
 - #88594 (More symbolic doc aliases)
 - #88648 (Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting)
 - #88691 (Add a regression test for #88649)
 - #88694 (Drop 1.56 stabilizations from 1.55 release notes)
 - #88712 (Fix docs for `uX::checked_next_multiple_of`)
 - #88726 (Fix typo in `const_generics` replaced with `adt_const_params` note)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index a1d3e9adba0..05156745105 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -516,6 +516,26 @@ impl<'a> Parser<'a> {
             token::BinOp(token::And) | token::AndAnd => {
                 make_it!(this, attrs, |this, _| this.parse_borrow_expr(lo))
             }
+            token::BinOp(token::Plus) if this.look_ahead(1, |tok| tok.is_numeric_lit()) => {
+                let mut err = this.struct_span_err(lo, "leading `+` is not supported");
+                err.span_label(lo, "unexpected `+`");
+
+                // a block on the LHS might have been intended to be an expression instead
+                if let Some(sp) = this.sess.ambiguous_block_expr_parse.borrow().get(&lo) {
+                    this.sess.expr_parentheses_needed(&mut err, *sp);
+                } else {
+                    err.span_suggestion_verbose(
+                        lo,
+                        "try removing the `+`",
+                        "".to_string(),
+                        Applicability::MachineApplicable,
+                    );
+                }
+                err.emit();
+
+                this.bump();
+                this.parse_prefix_expr(None)
+            } // `+expr`
             token::Ident(..) if this.token.is_keyword(kw::Box) => {
                 make_it!(this, attrs, |this, _| this.parse_box_expr(lo))
             }