diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2022-08-30 17:21:41 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2022-09-27 13:31:51 +0200 |
| commit | 8d9a5881ea18568f014ea09ec9d2f1d0cdacff1b (patch) | |
| tree | 651e2815dd82473a06eb287425b4a64530da6179 | |
| parent | 15754f5ea155600c62b8f4893fae78c5af1b08b2 (diff) | |
| download | rust-8d9a5881ea18568f014ea09ec9d2f1d0cdacff1b.tar.gz rust-8d9a5881ea18568f014ea09ec9d2f1d0cdacff1b.zip | |
Flatten if-let and match into one.
| -rw-r--r-- | compiler/rustc_builtin_macros/src/format.rs | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index f7c7e00ab22..1dd913ac6d2 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -285,26 +285,21 @@ pub fn make_format_args( -> FormatArgPosition { let index = match arg { Index(index) => { - if let Some((_, arg_kind)) = args.get(index) { - match arg_kind { - FormatArgKind::Normal => { - used[index] = true; - Ok(index) - } - FormatArgKind::Named(_) => { - used[index] = true; - numeric_refences_to_named_arg.push((index, span, used_as)); - Ok(index) - } - FormatArgKind::Captured(_) => { - // Doesn't exist as an explicit argument. - invalid_refs.push((index, span, used_as, kind)); - Err(index) - } + match args.get(index) { + Some((_, FormatArgKind::Normal)) => { + used[index] = true; + Ok(index) + } + Some((_, FormatArgKind::Named(_))) => { + used[index] = true; + numeric_refences_to_named_arg.push((index, span, used_as)); + Ok(index) + } + Some((_, FormatArgKind::Captured(_))) | None => { + // Doesn't exist as an explicit argument. + invalid_refs.push((index, span, used_as, kind)); + Err(index) } - } else { - invalid_refs.push((index, span, used_as, kind)); - Err(index) } } Name(name, span) => { |
