Closed
Description
Summary
.
Lint Name
print_literal
Reproducer
I tried this code:
fn main() {
println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
}
I saw this happen:
warning: literal with an empty format string
--> src/main.rs:2:41
|
2 | println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
| ^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#print_literal
= note: `#[warn(clippy::print_literal)]` on by default
help: try
|
2 - println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
2 + println!("Hello x is {1}", 5, 0.01);
|
The suggested code
fn main() {
println!("Hello x is {1}", 5, 0.01);
}
does not compile
error: argument never used
--> src/main.rs:2:32
|
2 | println!("Hello x is {1}", 5, 0.01);
| ---------------- ^ argument never used
| |
| formatting specifier missing
error: aborting due to 1 previous error
Original diagnostics will follow.
warning: literal with an empty format string
--> src/main.rs:2:41
|
2 | println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
| ^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#print_literal
= note: `#[warn(clippy::print_literal)]` on by default
help: try
|
2 - println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
2 + println!("Hello x is {1}", 5, 0.01);
|
``
### Version
```text
Additional Labels
No response