1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
11 #![feature(tool_lints)]
13 #![warn(clippy::print_literal)]
16 // these should be fine
20 println!("Hello {}", world);
21 println!("Hello {world}", world=world);
22 println!("3 in hex is {:X}", 3);
23 println!("2 + 1 = {:.4}", 3);
24 println!("2 + 1 = {:5.4}", 3);
25 println!("Debug test {:?}", "hello, world");
26 println!("{0:8} {1:>8}", "hello", "world");
27 println!("{1:8} {0:>8}", "hello", "world");
28 println!("{foo:8} {bar:>8}", foo="hello", bar="world");
29 println!("{bar:8} {foo:>8}", foo="hello", bar="world");
30 println!("{number:>width$}", number=1, width=6);
31 println!("{number:>0width$}", number=1, width=6);
33 // these should throw warnings
34 println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
35 print!("Hello {}", "world");
36 println!("Hello {} {}", world, "world");
37 println!("Hello {}", "world");
38 println!("10 / 4 is {}", 2.5);
39 println!("2 + 1 = {}", 3);
41 // positional args don't change the fact
42 // that we're using a literal -- this should
44 println!("{0} {1}", "hello", "world");
45 println!("{1} {0}", "hello", "world");
47 // named args shouldn't change anything either
48 println!("{foo} {bar}", foo="hello", bar="world");
49 println!("{bar} {foo}", foo="hello", bar="world");