diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-30 12:45:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 12:45:27 +0100 |
| commit | 78ded09912a6f64ab83978ab70b40ef7ff94b833 (patch) | |
| tree | 1c65d3230e153bfb880df0f043dda92499b9a15e /compiler/rustc_builtin_macros/src/format.rs | |
| parent | aedc0a34a842a3ec50a6d1d83a9fb98d5b1b9f3a (diff) | |
| parent | 5f01e12ea8035fdfc23eefaf6b580dbb9a8863ec (diff) | |
| download | rust-78ded09912a6f64ab83978ab70b40ef7ff94b833.tar.gz rust-78ded09912a6f64ab83978ab70b40ef7ff94b833.zip | |
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.
Diffstat (limited to 'compiler/rustc_builtin_macros/src/format.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/format.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index a0ab6375a66..7c746bd719f 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -101,15 +101,14 @@ fn parse_args<'a>(ecx: &ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, match p.expect(exp!(Comma)) { Err(err) => { - match token::TokenKind::Comma.similar_tokens() { - Some(tks) if tks.contains(&p.token.kind) => { - // If a similar token is found, then it may be a typo. We - // consider it as a comma, and continue parsing. - err.emit(); - p.bump(); - } + if token::TokenKind::Comma.similar_tokens().contains(&p.token.kind) { + // If a similar token is found, then it may be a typo. We + // consider it as a comma, and continue parsing. + err.emit(); + p.bump(); + } else { // Otherwise stop the parsing and return the error. - _ => return Err(err), + return Err(err); } } Ok(Recovered::Yes(_)) => (), |
