mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 06:30:32 +00:00
35 lines
1 KiB
Rust
35 lines
1 KiB
Rust
#![warn(clippy::unused_format_specs)]
|
|
#![allow(unused)]
|
|
|
|
macro_rules! format_args_from_macro {
|
|
() => {
|
|
format_args!("from macro")
|
|
};
|
|
}
|
|
|
|
fn main() {
|
|
// prints `.`, not ` .`
|
|
println!("{:5}.", format!(""));
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
|
//~| NOTE: `-D clippy::unused-format-specs` implied by `-D warnings`
|
|
//prints `abcde`, not `abc`
|
|
println!("{:.3}", format!("abcde"));
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
|
|
|
println!("{}.", format_args_from_macro!());
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
|
|
|
let args = format_args!("");
|
|
println!("{args}");
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
|
}
|
|
|
|
fn should_not_lint() {
|
|
println!("{}", format_args!(""));
|
|
// Technically the same as `{}`, but the `format_args` docs specifically mention that you can use
|
|
// debug formatting so allow it
|
|
println!("{:?}", format_args!(""));
|
|
|
|
let args = format_args!("");
|
|
println!("{args}");
|
|
}
|