Bring back suggestion for splitting <- into < -

Closes #62632
This commit is contained in:
Ilija Tovilo 2019-08-11 23:37:05 +02:00
parent 72f8043d44
commit 91af5c2daf
No known key found for this signature in database
GPG key ID: 3F123D0ADD448198
6 changed files with 33 additions and 8 deletions

View file

@ -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)
}