2022-10-23 08:18:45 -05:00
|
|
|
#![warn(clippy::unused_format_specs)]
|
|
|
|
#![allow(unused)]
|
2024-10-03 09:32:51 -05:00
|
|
|
|
2022-10-23 08:18:45 -05:00
|
|
|
macro_rules! format_args_from_macro {
|
|
|
|
() => {
|
|
|
|
format_args!("from macro")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// prints `.`, not ` .`
|
2024-10-03 09:32:51 -05:00
|
|
|
println!("{:5}.", format!(""));
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
|
|
|
//~| NOTE: `-D clippy::unused-format-specs` implied by `-D warnings`
|
2022-10-23 08:18:45 -05:00
|
|
|
//prints `abcde`, not `abc`
|
2024-10-03 09:32:51 -05:00
|
|
|
println!("{:.3}", format!("abcde"));
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
2022-10-23 08:18:45 -05:00
|
|
|
|
2024-10-03 09:32:51 -05:00
|
|
|
println!("{}.", format_args_from_macro!());
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
2022-10-23 08:18:45 -05:00
|
|
|
|
|
|
|
let args = format_args!("");
|
2024-10-03 09:32:51 -05:00
|
|
|
println!("{args}");
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: format specifiers have no effect on `format_args!()`
|
2022-10-23 08:18:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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}");
|
|
|
|
}
|