Skip to content

Commit 5631c74

Browse files
authored
Merge pull request #2086 from dtolnay/leftarrow
Fix left arrow being split into less-than and negative-sign
2 parents ec4c2da + c5b3cf0 commit 5631c74

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/expr.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,8 @@ pub(crate) mod parsing {
14861486
as_token,
14871487
ty: Box::new(ty),
14881488
});
1489+
} else if input.peek(Token![<-]) {
1490+
return Err(input.error("unexpected operator `<-`, if this is intended to be a comparison against a negative then a space is required: `< -`"));
14891491
} else {
14901492
break;
14911493
}
@@ -1529,6 +1531,8 @@ pub(crate) mod parsing {
15291531
as_token,
15301532
ty: Box::new(ty),
15311533
});
1534+
} else if input.peek(Token![<-]) {
1535+
return Err(input.error("unexpected operator `<-`, if this is intended to be a comparison against a negative then a space is required: `< -`"));
15321536
} else {
15331537
break;
15341538
}

‎src/op.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub(crate) mod parsing {
137137
input.parse().map(BinOp::BitAnd)
138138
} else if input.peek(Token![|]) {
139139
input.parse().map(BinOp::BitOr)
140-
} else if input.peek(Token![<]) {
140+
} else if input.peek(Token![<]) && !input.peek(Token![<-]) {
141141
input.parse().map(BinOp::Lt)
142142
} else if input.peek(Token![>]) {
143143
input.parse().map(BinOp::Gt)

0 commit comments

Comments
 (0)