We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
TokenKind::similar_tokens()
1 parent cf19131 commit 079c075Copy full SHA for 079c075
compiler/rustc_ast/src/token.rs
@@ -295,6 +295,7 @@ impl TokenKind {
295
match *self {
296
Comma => Some(vec![Dot, Lt, Semi]),
297
Semi => Some(vec![Colon, Comma]),
298
+ FatArrow => Some(vec![Eq, RArrow]),
299
_ => None,
300
}
301
compiler/rustc_parse/src/parser/expr.rs
@@ -2324,7 +2324,10 @@ impl<'a> Parser<'a> {
2324
let arrow_span = this.token.span;
2325
if let Err(mut err) = this.expect(&token::FatArrow) {
2326
// We might have a `=>` -> `=` or `->` typo (issue #89396).
2327
- if let token::Eq | token::RArrow = this.token.kind {
+ if TokenKind::FatArrow
2328
+ .similar_tokens()
2329
+ .map_or(false, |similar_tokens| similar_tokens.contains(&this.token.kind))
2330
+ {
2331
err.span_suggestion(
2332
this.token.span,
2333
"try using a fat arrow here",
0 commit comments