]> git.lizzy.rs Git - rust.git/blob - tests/ui/format.rs
Merge pull request #2065 from rust-lang-nursery/cargo_clippy
[rust.git] / tests / ui / format.rs
1
2
3 #![warn(useless_format)]
4
5 fn main() {
6     format!("foo");
7
8     format!("{}", "foo");
9     format!("{:?}", "foo"); // we only want to warn about `{}`
10     format!("{:+}", "foo"); // we only want to warn about `{}`
11     format!("foo {}", "bar");
12     format!("{} bar", "foo");
13
14     let arg: String = "".to_owned();
15     format!("{}", arg);
16     format!("{:?}", arg); // we only want to warn about `{}`
17     format!("{:+}", arg); // we only want to warn about `{}`
18     format!("foo {}", arg);
19     format!("{} bar", arg);
20
21     // we don’t want to warn for non-string args, see #697
22     format!("{}", 42);
23     format!("{:?}", 42);
24     format!("{:+}", 42);
25     format!("foo {}", 42);
26     format!("{} bar", 42);
27
28     // we only want to warn about `format!` itself
29     println!("foo");
30     println!("{}", "foo");
31     println!("foo {}", "foo");
32     println!("{}", 42);
33     println!("foo {}", 42);
34 }