1 #![feature(tool_lints)]
2 #![allow(clippy::print_literal)]
3 #![warn(clippy::useless_format)]
5 struct Foo(pub String);
8 ($($t:tt)*) => (Foo(format!($($t)*)))
15 format!("{:?}", "foo"); // don't warn about debug
16 format!("{:8}", "foo");
17 format!("{:+}", "foo"); // warn when the format makes no difference
18 format!("{:<}", "foo"); // warn when the format makes no difference
19 format!("foo {}", "bar");
20 format!("{} bar", "foo");
22 let arg: String = "".to_owned();
24 format!("{:?}", arg); // don't warn about debug
26 format!("{:+}", arg); // warn when the format makes no difference
27 format!("{:<}", arg); // warn when the format makes no difference
28 format!("foo {}", arg);
29 format!("{} bar", arg);
31 // we don’t want to warn for non-string args, see #697
35 format!("foo {}", 42);
36 format!("{} bar", 42);
38 // we only want to warn about `format!` itself
40 println!("{}", "foo");
41 println!("foo {}", "foo");
43 println!("foo {}", 42);
45 // A format! inside a macro should not trigger a warning
46 foo!("should not warn");