about summary refs log tree commit diff
path: root/compiler/rustc_parse_format
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-02-08 22:12:13 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-02-08 22:12:13 +0000
commit1fcae03369abb4c2cc180cd5a49e1f4440a81300 (patch)
treefe705ff77c286f5fc4c09acc98d2f124086d0479 /compiler/rustc_parse_format
parent3183b44a1ec209b06e0c26cbc92217176b59dc76 (diff)
downloadrust-1fcae03369abb4c2cc180cd5a49e1f4440a81300.tar.gz
rust-1fcae03369abb4c2cc180cd5a49e1f4440a81300.zip
Rustfmt
Diffstat (limited to 'compiler/rustc_parse_format')
-rw-r--r--compiler/rustc_parse_format/src/lib.rs101
-rw-r--r--compiler/rustc_parse_format/src/tests.rs640
2 files changed, 411 insertions, 330 deletions
diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs
index d021ea107ed..3b985621b57 100644
--- a/compiler/rustc_parse_format/src/lib.rs
+++ b/compiler/rustc_parse_format/src/lib.rs
@@ -863,28 +863,34 @@ impl<'a> Parser<'a> {
         if let (Some(pos), Some(_)) = (self.consume_pos('?'), self.consume_pos(':')) {
             let word = self.word();
             let pos = self.to_span_index(pos);
-            self.errors.insert(0, ParseError {
-                description: "expected format parameter to occur after `:`".to_owned(),
-                note: Some(format!("`?` comes after `:`, try `{}:{}` instead", word, "?")),
-                label: "expected `?` to occur after `:`".to_owned(),
-                span: pos.to(pos),
-                secondary_label: None,
-                suggestion: Suggestion::None,
-            });
+            self.errors.insert(
+                0,
+                ParseError {
+                    description: "expected format parameter to occur after `:`".to_owned(),
+                    note: Some(format!("`?` comes after `:`, try `{}:{}` instead", word, "?")),
+                    label: "expected `?` to occur after `:`".to_owned(),
+                    span: pos.to(pos),
+                    secondary_label: None,
+                    suggestion: Suggestion::None,
+                },
+            );
         }
     }
 
     fn suggest_format_align(&mut self, alignment: char) {
         if let Some(pos) = self.consume_pos(alignment) {
             let pos = self.to_span_index(pos);
-            self.errors.insert(0, ParseError {
-                description: "expected format parameter to occur after `:`".to_owned(),
-                note: None,
-                label: format!("expected `{}` to occur after `:`", alignment),
-                span: pos.to(pos),
-                secondary_label: None,
-                suggestion: Suggestion::None,
-            });
+            self.errors.insert(
+                0,
+                ParseError {
+                    description: "expected format parameter to occur after `:`".to_owned(),
+                    note: None,
+                    label: format!("expected `{}` to occur after `:`", alignment),
+                    span: pos.to(pos),
+                    secondary_label: None,
+                    suggestion: Suggestion::None,
+                },
+            );
         }
     }
 
@@ -901,24 +907,36 @@ impl<'a> Parser<'a> {
             if let ArgumentNamed(_) = arg.position {
                 match field.position {
                     ArgumentNamed(_) => {
-                        self.errors.insert(0, ParseError {
-                            description: "field access isn't supported".to_string(),
-                            note: None,
-                            label: "not supported".to_string(),
-                            span: InnerSpan::new(arg.position_span.start, field.position_span.end),
-                            secondary_label: None,
-                            suggestion: Suggestion::UsePositional,
-                        });
+                        self.errors.insert(
+                            0,
+                            ParseError {
+                                description: "field access isn't supported".to_string(),
+                                note: None,
+                                label: "not supported".to_string(),
+                                span: InnerSpan::new(
+                                    arg.position_span.start,
+                                    field.position_span.end,
+                                ),
+                                secondary_label: None,
+                                suggestion: Suggestion::UsePositional,
+                            },
+                        );
                     }
                     ArgumentIs(_) => {
-                        self.errors.insert(0, ParseError {
-                            description: "tuple index access isn't supported".to_string(),
-                            note: None,
-                            label: "not supported".to_string(),
-                            span: InnerSpan::new(arg.position_span.start, field.position_span.end),
-                            secondary_label: None,
-                            suggestion: Suggestion::UsePositional,
-                        });
+                        self.errors.insert(
+                            0,
+                            ParseError {
+                                description: "tuple index access isn't supported".to_string(),
+                                note: None,
+                                label: "not supported".to_string(),
+                                span: InnerSpan::new(
+                                    arg.position_span.start,
+                                    field.position_span.end,
+                                ),
+                                secondary_label: None,
+                                suggestion: Suggestion::UsePositional,
+                            },
+                        );
                     }
                     _ => {}
                 };
@@ -940,14 +958,17 @@ impl<'a> Parser<'a> {
         let span = self.span(pos - 1, pos + 1);
         let pos = self.to_span_index(pos);
 
-        self.errors.insert(0, ParseError {
-            description: format!("expected `}}`, found `{c}`"),
-            note: None,
-            label: "expected `'}'`".into(),
-            span: pos.to(pos),
-            secondary_label: None,
-            suggestion: Suggestion::ReorderFormatParameter(span, format!("{replacement}")),
-        })
+        self.errors.insert(
+            0,
+            ParseError {
+                description: format!("expected `}}`, found `{c}`"),
+                note: None,
+                label: "expected `'}'`".into(),
+                span: pos.to(pos),
+                secondary_label: None,
+                suggestion: Suggestion::ReorderFormatParameter(span, format!("{replacement}")),
+            },
+        )
     }
 }
 
diff --git a/compiler/rustc_parse_format/src/tests.rs b/compiler/rustc_parse_format/src/tests.rs
index fbb217b16fc..cc8a0069c4e 100644
--- a/compiler/rustc_parse_format/src/tests.rs
+++ b/compiler/rustc_parse_format/src/tests.rs
@@ -80,307 +80,311 @@ fn invalid_precision() {
 
 #[test]
 fn format_nothing() {
-    same("{}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: fmtdflt(),
-    }))]);
+    same(
+        "{}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: fmtdflt(),
+        }))],
+    );
 }
 #[test]
 fn format_position() {
-    same("{3}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(3),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: fmtdflt(),
-    }))]);
+    same(
+        "{3}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(3),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: fmtdflt(),
+        }))],
+    );
 }
 #[test]
 fn format_position_nothing_else() {
-    same("{3:}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(3),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: fmtdflt(),
-    }))]);
+    same(
+        "{3:}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(3),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: fmtdflt(),
+        }))],
+    );
 }
 #[test]
 fn format_named() {
-    same("{name}", &[NextArgument(Box::new(Argument {
-        position: ArgumentNamed("name"),
-        position_span: InnerSpan { start: 2, end: 6 },
-        format: fmtdflt(),
-    }))])
+    same(
+        "{name}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentNamed("name"),
+            position_span: InnerSpan { start: 2, end: 6 },
+            format: fmtdflt(),
+        }))],
+    )
 }
 #[test]
 fn format_type() {
-    same("{3:x}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(3),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            width: CountImplied,
-            precision_span: None,
-            width_span: None,
-            ty: "x",
-            ty_span: None,
-        },
-    }))]);
+    same(
+        "{3:x}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(3),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountImplied,
+                width: CountImplied,
+                precision_span: None,
+                width_span: None,
+                ty: "x",
+                ty_span: None,
+            },
+        }))],
+    );
 }
 #[test]
 fn format_align_fill() {
-    same("{3:>}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(3),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignRight,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            width: CountImplied,
-            precision_span: None,
-            width_span: None,
-            ty: "",
-            ty_span: None,
-        },
-    }))]);
-    same("{3:0<}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(3),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: FormatSpec {
-            fill: Some('0'),
-            fill_span: Some(InnerSpan::new(4, 5)),
-            align: AlignLeft,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            width: CountImplied,
-            precision_span: None,
-            width_span: None,
-            ty: "",
-            ty_span: None,
-        },
-    }))]);
-    same("{3:*<abcd}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(3),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: FormatSpec {
-            fill: Some('*'),
-            fill_span: Some(InnerSpan::new(4, 5)),
-            align: AlignLeft,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            width: CountImplied,
-            precision_span: None,
-            width_span: None,
-            ty: "abcd",
-            ty_span: Some(InnerSpan::new(6, 10)),
-        },
-    }))]);
+    same(
+        "{3:>}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(3),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignRight,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountImplied,
+                width: CountImplied,
+                precision_span: None,
+                width_span: None,
+                ty: "",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{3:0<}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(3),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: FormatSpec {
+                fill: Some('0'),
+                fill_span: Some(InnerSpan::new(4, 5)),
+                align: AlignLeft,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountImplied,
+                width: CountImplied,
+                precision_span: None,
+                width_span: None,
+                ty: "",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{3:*<abcd}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(3),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: FormatSpec {
+                fill: Some('*'),
+                fill_span: Some(InnerSpan::new(4, 5)),
+                align: AlignLeft,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountImplied,
+                width: CountImplied,
+                precision_span: None,
+                width_span: None,
+                ty: "abcd",
+                ty_span: Some(InnerSpan::new(6, 10)),
+            },
+        }))],
+    );
 }
 #[test]
 fn format_counts() {
-    same("{:10x}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            precision_span: None,
-            width: CountIs(10),
-            width_span: Some(InnerSpan { start: 3, end: 5 }),
-            ty: "x",
-            ty_span: None,
-        },
-    }))]);
-    same("{:10$.10x}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountIs(10),
-            precision_span: Some(InnerSpan { start: 6, end: 9 }),
-            width: CountIsParam(10),
-            width_span: Some(InnerSpan { start: 3, end: 6 }),
-            ty: "x",
-            ty_span: None,
-        },
-    }))]);
-    same("{1:0$.10x}", &[NextArgument(Box::new(Argument {
-        position: ArgumentIs(1),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountIs(10),
-            precision_span: Some(InnerSpan { start: 6, end: 9 }),
-            width: CountIsParam(0),
-            width_span: Some(InnerSpan { start: 4, end: 6 }),
-            ty: "x",
-            ty_span: None,
-        },
-    }))]);
-    same("{:.*x}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(1),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountIsStar(0),
-            precision_span: Some(InnerSpan { start: 3, end: 5 }),
-            width: CountImplied,
-            width_span: None,
-            ty: "x",
-            ty_span: None,
-        },
-    }))]);
-    same("{:.10$x}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountIsParam(10),
-            width: CountImplied,
-            precision_span: Some(InnerSpan::new(3, 7)),
-            width_span: None,
-            ty: "x",
-            ty_span: None,
-        },
-    }))]);
-    same("{:a$.b$?}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountIsName("b", InnerSpan { start: 6, end: 7 }),
-            precision_span: Some(InnerSpan { start: 5, end: 8 }),
-            width: CountIsName("a", InnerSpan { start: 3, end: 4 }),
-            width_span: Some(InnerSpan { start: 3, end: 5 }),
-            ty: "?",
-            ty_span: None,
-        },
-    }))]);
-    same("{:.4}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: None,
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountIs(4),
-            precision_span: Some(InnerSpan { start: 3, end: 5 }),
-            width: CountImplied,
-            width_span: None,
-            ty: "",
-            ty_span: None,
-        },
-    }))])
+    same(
+        "{:10x}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountImplied,
+                precision_span: None,
+                width: CountIs(10),
+                width_span: Some(InnerSpan { start: 3, end: 5 }),
+                ty: "x",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{:10$.10x}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountIs(10),
+                precision_span: Some(InnerSpan { start: 6, end: 9 }),
+                width: CountIsParam(10),
+                width_span: Some(InnerSpan { start: 3, end: 6 }),
+                ty: "x",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{1:0$.10x}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentIs(1),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountIs(10),
+                precision_span: Some(InnerSpan { start: 6, end: 9 }),
+                width: CountIsParam(0),
+                width_span: Some(InnerSpan { start: 4, end: 6 }),
+                ty: "x",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{:.*x}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(1),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountIsStar(0),
+                precision_span: Some(InnerSpan { start: 3, end: 5 }),
+                width: CountImplied,
+                width_span: None,
+                ty: "x",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{:.10$x}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountIsParam(10),
+                width: CountImplied,
+                precision_span: Some(InnerSpan::new(3, 7)),
+                width_span: None,
+                ty: "x",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{:a$.b$?}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountIsName("b", InnerSpan { start: 6, end: 7 }),
+                precision_span: Some(InnerSpan { start: 5, end: 8 }),
+                width: CountIsName("a", InnerSpan { start: 3, end: 4 }),
+                width_span: Some(InnerSpan { start: 3, end: 5 }),
+                ty: "?",
+                ty_span: None,
+            },
+        }))],
+    );
+    same(
+        "{:.4}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: None,
+                alternate: false,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountIs(4),
+                precision_span: Some(InnerSpan { start: 3, end: 5 }),
+                width: CountImplied,
+                width_span: None,
+                ty: "",
+                ty_span: None,
+            },
+        }))],
+    )
 }
 #[test]
 fn format_flags() {
-    same("{:-}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: Some(Sign::Minus),
-            alternate: false,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            width: CountImplied,
-            precision_span: None,
-            width_span: None,
-            ty: "",
-            ty_span: None,
-        },
-    }))]);
-    same("{:+#}", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 2 },
-        format: FormatSpec {
-            fill: None,
-            fill_span: None,
-            align: AlignUnknown,
-            sign: Some(Sign::Plus),
-            alternate: true,
-            zero_pad: false,
-            debug_hex: None,
-            precision: CountImplied,
-            width: CountImplied,
-            precision_span: None,
-            width_span: None,
-            ty: "",
-            ty_span: None,
-        },
-    }))]);
-}
-#[test]
-fn format_mixture() {
-    same("abcd {3:x} efg", &[
-        Lit("abcd "),
-        NextArgument(Box::new(Argument {
-            position: ArgumentIs(3),
-            position_span: InnerSpan { start: 7, end: 8 },
+    same(
+        "{:-}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
             format: FormatSpec {
                 fill: None,
                 fill_span: None,
                 align: AlignUnknown,
-                sign: None,
+                sign: Some(Sign::Minus),
                 alternate: false,
                 zero_pad: false,
                 debug_hex: None,
@@ -388,23 +392,79 @@ fn format_mixture() {
                 width: CountImplied,
                 precision_span: None,
                 width_span: None,
-                ty: "x",
+                ty: "",
                 ty_span: None,
             },
-        })),
-        Lit(" efg"),
-    ]);
+        }))],
+    );
+    same(
+        "{:+#}",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 2 },
+            format: FormatSpec {
+                fill: None,
+                fill_span: None,
+                align: AlignUnknown,
+                sign: Some(Sign::Plus),
+                alternate: true,
+                zero_pad: false,
+                debug_hex: None,
+                precision: CountImplied,
+                width: CountImplied,
+                precision_span: None,
+                width_span: None,
+                ty: "",
+                ty_span: None,
+            },
+        }))],
+    );
+}
+#[test]
+fn format_mixture() {
+    same(
+        "abcd {3:x} efg",
+        &[
+            Lit("abcd "),
+            NextArgument(Box::new(Argument {
+                position: ArgumentIs(3),
+                position_span: InnerSpan { start: 7, end: 8 },
+                format: FormatSpec {
+                    fill: None,
+                    fill_span: None,
+                    align: AlignUnknown,
+                    sign: None,
+                    alternate: false,
+                    zero_pad: false,
+                    debug_hex: None,
+                    precision: CountImplied,
+                    width: CountImplied,
+                    precision_span: None,
+                    width_span: None,
+                    ty: "x",
+                    ty_span: None,
+                },
+            })),
+            Lit(" efg"),
+        ],
+    );
 }
 #[test]
 fn format_whitespace() {
-    same("{ }", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 3 },
-        format: fmtdflt(),
-    }))]);
-    same("{  }", &[NextArgument(Box::new(Argument {
-        position: ArgumentImplicitlyIs(0),
-        position_span: InnerSpan { start: 2, end: 4 },
-        format: fmtdflt(),
-    }))]);
+    same(
+        "{ }",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 3 },
+            format: fmtdflt(),
+        }))],
+    );
+    same(
+        "{  }",
+        &[NextArgument(Box::new(Argument {
+            position: ArgumentImplicitlyIs(0),
+            position_span: InnerSpan { start: 2, end: 4 },
+            format: fmtdflt(),
+        }))],
+    );
 }