Skip to content

Commit 079c075

Browse files
committed
Use TokenKind::similar_tokens()
1 parent cf19131 commit 079c075

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/rustc_ast/src/token.rs

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl TokenKind {
295295
match *self {
296296
Comma => Some(vec![Dot, Lt, Semi]),
297297
Semi => Some(vec![Colon, Comma]),
298+
FatArrow => Some(vec![Eq, RArrow]),
298299
_ => None,
299300
}
300301
}

compiler/rustc_parse/src/parser/expr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,10 @@ impl<'a> Parser<'a> {
23242324
let arrow_span = this.token.span;
23252325
if let Err(mut err) = this.expect(&token::FatArrow) {
23262326
// We might have a `=>` -> `=` or `->` typo (issue #89396).
2327-
if let token::Eq | token::RArrow = this.token.kind {
2327+
if TokenKind::FatArrow
2328+
.similar_tokens()
2329+
.map_or(false, |similar_tokens| similar_tokens.contains(&this.token.kind))
2330+
{
23282331
err.span_suggestion(
23292332
this.token.span,
23302333
"try using a fat arrow here",

0 commit comments

Comments
 (0)