Skip to content

Commit aebad39

Browse files
committed
Add test for {:.0$} diagnostic issue.
1 parent 1b044da commit aebad39

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/test/ui/fmt/ifmt-bad-arg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,6 @@ tenth number: {}",
9494
// doesn't exist.
9595
println!("{:.*}");
9696
//~^ ERROR 2 positional arguments in format string, but no arguments were given
97+
println!("{:.0$}");
98+
//~^ ERROR 1 positional argument in format string, but no arguments were given
9799
}

src/test/ui/fmt/ifmt-bad-arg.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,17 @@ LL | println!("{:.*}");
273273
= note: positional arguments are zero-based
274274
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
275275

276+
error: 1 positional argument in format string, but no arguments were given
277+
--> $DIR/ifmt-bad-arg.rs:97:15
278+
|
279+
LL | println!("{:.0$}");
280+
| ^^---^
281+
| |
282+
| this precision flag expects an `usize` argument at position 0, but no arguments were given
283+
|
284+
= note: positional arguments are zero-based
285+
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
286+
276287
error[E0425]: cannot find value `foo` in this scope
277288
--> $DIR/ifmt-bad-arg.rs:27:18
278289
|
@@ -339,7 +350,7 @@ LL | pub fn from_usize(x: &usize) -> ArgumentV1<'_> {
339350
| ^^^^^^^^^^
340351
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
341352

342-
error: aborting due to 37 previous errors
353+
error: aborting due to 38 previous errors
343354

344355
Some errors have detailed explanations: E0308, E0425.
345356
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)