diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-14 04:18:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-14 04:18:42 +0200 |
| commit | c8248394715ae4a6c88ee14b10ad526a54259520 (patch) | |
| tree | ff390be741b1394efd2511aa2900cb08525dd7eb /src/libsyntax/parse/parser | |
| parent | 76bd7d62d6ff665631d5415eadebc8142f0aee2d (diff) | |
| parent | 91af5c2daf950bd6f99e17dd2e0d23e7cd45e131 (diff) | |
| download | rust-c8248394715ae4a6c88ee14b10ad526a54259520.tar.gz rust-c8248394715ae4a6c88ee14b10ad526a54259520.zip | |
Rollup merge of #63475 - iluuu1994:issue-62632, r=Centril
Bring back suggestion for splitting `<-` into `< -` Closes #62632
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/expr.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 4432c1329cb..4fdb000ed90 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -224,6 +224,10 @@ impl<'a> Parser<'a> { self.err_dotdotdot_syntax(self.token.span); } + if self.token == token::LArrow { + self.err_larrow_operator(self.token.span); + } + self.bump(); if op.is_comparison() { self.check_no_chained_comparison(&lhs, &op); @@ -1702,6 +1706,19 @@ impl<'a> Parser<'a> { .emit(); } + fn err_larrow_operator(&self, span: Span) { + self.struct_span_err( + span, + "unexpected token: `<-`" + ).span_suggestion( + span, + "if you meant to write a comparison against a negative value, add a \ + space in between `<` and `-`", + "< -".to_string(), + Applicability::MaybeIncorrect + ).emit(); + } + fn mk_assign_op(&self, binop: BinOp, lhs: P<Expr>, rhs: P<Expr>) -> ExprKind { ExprKind::AssignOp(binop, lhs, rhs) } |
