]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/unused_format_specs_unfixable.rs
Rollup merge of #105801 - zertosh:path_mut_os_str_doc_test, r=dtolnay
[rust.git] / src / tools / clippy / tests / ui / unused_format_specs_unfixable.rs
1 #![warn(clippy::unused_format_specs)]
2 #![allow(unused)]
3
4 macro_rules! format_args_from_macro {
5     () => {
6         format_args!("from macro")
7     };
8 }
9
10 fn main() {
11     // prints `.`, not `     .`
12     println!("{:5}.", format_args!(""));
13     //prints `abcde`, not `abc`
14     println!("{:.3}", format_args!("abcde"));
15
16     println!("{:5}.", format_args_from_macro!());
17
18     let args = format_args!("");
19     println!("{args:5}");
20 }
21
22 fn should_not_lint() {
23     println!("{}", format_args!(""));
24     // Technically the same as `{}`, but the `format_args` docs specifically mention that you can use
25     // debug formatting so allow it
26     println!("{:?}", format_args!(""));
27
28     let args = format_args!("");
29     println!("{args}");
30 }