diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-08-03 11:28:00 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-08-03 11:28:00 +0900 |
| commit | a0a2ec332621d35b92633dc4db0451e0c3cb4ab2 (patch) | |
| tree | 097453c833103275b49bcc4581aea1cce1aab0ea | |
| parent | 4233a13cebe176139d8d16d18f507b90852ddab0 (diff) | |
| download | rust-a0a2ec332621d35b92633dc4db0451e0c3cb4ab2.tar.gz rust-a0a2ec332621d35b92633dc4db0451e0c3cb4ab2.zip | |
add tests for `Debug` formatters and precision formatters
| -rw-r--r-- | src/test/ui/fmt/struct-field-as-captured-argument.fixed | 3 | ||||
| -rw-r--r-- | src/test/ui/fmt/struct-field-as-captured-argument.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/fmt/struct-field-as-captured-argument.stderr | 35 |
3 files changed, 40 insertions, 1 deletions
diff --git a/src/test/ui/fmt/struct-field-as-captured-argument.fixed b/src/test/ui/fmt/struct-field-as-captured-argument.fixed index a8d7b44fb3d..f7244f6744f 100644 --- a/src/test/ui/fmt/struct-field-as-captured-argument.fixed +++ b/src/test/ui/fmt/struct-field-as-captured-argument.fixed @@ -12,4 +12,7 @@ fn main() { format!("{1} {} {bar}", "aa", foo.field); //~ ERROR invalid format string: field access isn't supported format!("{2} {} {1} {bar}", "aa", "bb", foo.field); //~ ERROR invalid format string: field access isn't supported format!("{1} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported + format!("{1:?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported + format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported + format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported } diff --git a/src/test/ui/fmt/struct-field-as-captured-argument.rs b/src/test/ui/fmt/struct-field-as-captured-argument.rs index e23c14190b0..ab5f2552bd3 100644 --- a/src/test/ui/fmt/struct-field-as-captured-argument.rs +++ b/src/test/ui/fmt/struct-field-as-captured-argument.rs @@ -12,4 +12,7 @@ fn main() { format!("{foo.field} {} {bar}", "aa"); //~ ERROR invalid format string: field access isn't supported format!("{foo.field} {} {1} {bar}", "aa", "bb"); //~ ERROR invalid format string: field access isn't supported format!("{foo.field} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported + format!("{foo.field:?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported + format!("{foo.field:#?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported + format!("{foo.field:.3} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported } diff --git a/src/test/ui/fmt/struct-field-as-captured-argument.stderr b/src/test/ui/fmt/struct-field-as-captured-argument.stderr index 28d3c8f838b..7ea8b4068f2 100644 --- a/src/test/ui/fmt/struct-field-as-captured-argument.stderr +++ b/src/test/ui/fmt/struct-field-as-captured-argument.stderr @@ -42,5 +42,38 @@ help: consider using a positional formatting argument instead LL | format!("{1} {} {baz}", "aa", foo.field, baz = 3); | ~ +++++++++++ -error: aborting due to 4 previous errors +error: invalid format string: field access isn't supported + --> $DIR/struct-field-as-captured-argument.rs:15:15 + | +LL | format!("{foo.field:?} {} {baz}", "aa", baz = 3); + | ^^^^^^^^^ not supported in format string + | +help: consider using a positional formatting argument instead + | +LL | format!("{1:?} {} {baz}", "aa", foo.field, baz = 3); + | ~ +++++++++++ + +error: invalid format string: field access isn't supported + --> $DIR/struct-field-as-captured-argument.rs:16:15 + | +LL | format!("{foo.field:#?} {} {baz}", "aa", baz = 3); + | ^^^^^^^^^ not supported in format string + | +help: consider using a positional formatting argument instead + | +LL | format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3); + | ~ +++++++++++ + +error: invalid format string: field access isn't supported + --> $DIR/struct-field-as-captured-argument.rs:17:15 + | +LL | format!("{foo.field:.3} {} {baz}", "aa", baz = 3); + | ^^^^^^^^^ not supported in format string + | +help: consider using a positional formatting argument instead + | +LL | format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3); + | ~ +++++++++++ + +error: aborting due to 7 previous errors |
