Use TokenKind::similar_tokens()
This commit is contained in:
parent
cf19131cb3
commit
079c075f24
2 changed files with 5 additions and 1 deletions
|
@ -295,6 +295,7 @@ impl TokenKind {
|
||||||
match *self {
|
match *self {
|
||||||
Comma => Some(vec![Dot, Lt, Semi]),
|
Comma => Some(vec![Dot, Lt, Semi]),
|
||||||
Semi => Some(vec![Colon, Comma]),
|
Semi => Some(vec![Colon, Comma]),
|
||||||
|
FatArrow => Some(vec![Eq, RArrow]),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2324,7 +2324,10 @@ impl<'a> Parser<'a> {
|
||||||
let arrow_span = this.token.span;
|
let arrow_span = this.token.span;
|
||||||
if let Err(mut err) = this.expect(&token::FatArrow) {
|
if let Err(mut err) = this.expect(&token::FatArrow) {
|
||||||
// We might have a `=>` -> `=` or `->` typo (issue #89396).
|
// We might have a `=>` -> `=` or `->` typo (issue #89396).
|
||||||
if let token::Eq | token::RArrow = this.token.kind {
|
if TokenKind::FatArrow
|
||||||
|
.similar_tokens()
|
||||||
|
.map_or(false, |similar_tokens| similar_tokens.contains(&this.token.kind))
|
||||||
|
{
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
this.token.span,
|
this.token.span,
|
||||||
"try using a fat arrow here",
|
"try using a fat arrow here",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue