parent
72f8043d44
commit
91af5c2daf
6 changed files with 33 additions and 8 deletions
|
@ -224,6 +224,10 @@ impl<'a> Parser<'a> {
|
||||||
self.err_dotdotdot_syntax(self.token.span);
|
self.err_dotdotdot_syntax(self.token.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.token == token::LArrow {
|
||||||
|
self.err_larrow_operator(self.token.span);
|
||||||
|
}
|
||||||
|
|
||||||
self.bump();
|
self.bump();
|
||||||
if op.is_comparison() {
|
if op.is_comparison() {
|
||||||
self.check_no_chained_comparison(&lhs, &op);
|
self.check_no_chained_comparison(&lhs, &op);
|
||||||
|
@ -1702,6 +1706,19 @@ impl<'a> Parser<'a> {
|
||||||
.emit();
|
.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 {
|
fn mk_assign_op(&self, binop: BinOp, lhs: P<Expr>, rhs: P<Expr>) -> ExprKind {
|
||||||
ExprKind::AssignOp(binop, lhs, rhs)
|
ExprKind::AssignOp(binop, lhs, rhs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,8 @@ impl AssocOp {
|
||||||
// DotDotDot is no longer supported, but we need some way to display the error
|
// DotDotDot is no longer supported, but we need some way to display the error
|
||||||
token::DotDotDot => Some(DotDotEq),
|
token::DotDotDot => Some(DotDotEq),
|
||||||
token::Colon => Some(Colon),
|
token::Colon => Some(Colon),
|
||||||
|
// `<-` should probably be `< -`
|
||||||
|
token::LArrow => Some(Less),
|
||||||
_ if t.is_keyword(kw::As) => Some(As),
|
_ if t.is_keyword(kw::As) => Some(As),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let (x, y) = (0, 0);
|
let (x, y) = (0, 0);
|
||||||
x <- y; //~ ERROR expected one of
|
x <- y; //~ ERROR unexpected token: `<-`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `<-`
|
error: unexpected token: `<-`
|
||||||
--> $DIR/bad.rs:5:7
|
--> $DIR/bad.rs:5:7
|
||||||
|
|
|
|
||||||
LL | x <- y;
|
LL | x <- y;
|
||||||
| ^^ expected one of 8 possible tokens here
|
| ^^
|
||||||
|
help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
|
||||||
|
|
|
||||||
|
LL | x < - y;
|
||||||
|
| ^^^
|
||||||
|
|
||||||
error: expected expression, found keyword `in`
|
error: expected expression, found keyword `in`
|
||||||
--> $DIR/bad.rs:10:5
|
--> $DIR/bad.rs:10:5
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = -5;
|
let x = -5;
|
||||||
if x<-1 { //~ ERROR expected `{`, found `<-`
|
if x<-1 { //~ ERROR unexpected token: `<-`
|
||||||
println!("ok");
|
println!("ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
error: expected `{`, found `<-`
|
error: unexpected token: `<-`
|
||||||
--> $DIR/placement-syntax.rs:3:9
|
--> $DIR/placement-syntax.rs:3:9
|
||||||
|
|
|
|
||||||
LL | if x<-1 {
|
LL | if x<-1 {
|
||||||
| -- ^^ expected `{`
|
| ^^
|
||||||
| |
|
help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
|
||||||
| this `if` statement has a condition, but no block
|
|
|
||||||
|
LL | if x< -1 {
|
||||||
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue