Rollup merge of #135882 - hkBst:master, r=estebank

simplify `similar_tokens` from `Option<Vec<_>>` to `&[_]`

All uses immediately invoke contains, so maybe a further simplification is possible.
This commit is contained in:
Matthias Krüger 2025-01-30 12:45:27 +01:00 committed by GitHub
commit 78ded09912
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 22 deletions

View file

@ -3114,9 +3114,8 @@ impl<'a> Parser<'a> {
let span_before_body = this.prev_token.span;
let arm_body;
let is_fat_arrow = this.check(exp!(FatArrow));
let is_almost_fat_arrow = TokenKind::FatArrow
.similar_tokens()
.is_some_and(|similar_tokens| similar_tokens.contains(&this.token.kind));
let is_almost_fat_arrow =
TokenKind::FatArrow.similar_tokens().contains(&this.token.kind);
// this avoids the compiler saying that a `,` or `}` was expected even though
// the pattern isn't a never pattern (and thus an arm body is required)

View file

@ -924,10 +924,8 @@ impl<'a> Parser<'a> {
_ => {
// Attempt to keep parsing if it was a similar separator.
if let Some(tokens) = exp.tok.similar_tokens() {
if tokens.contains(&self.token.kind) {
self.bump();
}
if exp.tok.similar_tokens().contains(&self.token.kind) {
self.bump();
}
}
}