summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unused_format_specs_unfixable.rs
blob: 78601a3483d347428d5f2fededb5b42cb6a5d5ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#![warn(clippy::unused_format_specs)]
#![allow(unused)]

macro_rules! format_args_from_macro {
    () => {
        format_args!("from macro")
    };
}

fn main() {
    // prints `.`, not `     .`
    println!("{:5}.", format_args!(""));
    //prints `abcde`, not `abc`
    println!("{:.3}", format_args!("abcde"));

    println!("{:5}.", format_args_from_macro!());

    let args = format_args!("");
    println!("{args:5}");
}

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}");
}