]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/unused_format_specs.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / unused_format_specs.txt
1 ### What it does
2 Detects [formatting parameters] that have no effect on the output of
3 `format!()`, `println!()` or similar macros.
4
5 ### Why is this bad?
6 Shorter format specifiers are easier to read, it may also indicate that
7 an expected formatting operation such as adding padding isn't happening.
8
9 ### Example
10 ```
11 println!("{:.}", 1.0);
12
13 println!("not padded: {:5}", format_args!("..."));
14 ```
15 Use instead:
16 ```
17 println!("{}", 1.0);
18
19 println!("not padded: {}", format_args!("..."));
20 // OR
21 println!("padded: {:5}", format!("..."));
22 ```
23
24 [formatting parameters]: https://doc.rust-lang.org/std/fmt/index.html#formatting-parameters