3 #![warn(print_literal)]
6 // these should be fine
10 println!("Hello {}", world);
11 println!("3 in hex is {:X}", 3);
13 // this in theory shouldn't yield a warning,
14 // but at present time, it's a known edge case
15 // that isn't handled (because we can't expand
16 // `println!` and not `env!`)
17 println!("foo: {}", env!("BAR"));
19 // these should throw warnings
20 print!("Hello {}", "world");
21 println!("Hello {} {}", world, "world");
22 println!("Hello {}", "world");
23 println!("10 / 4 is {}", 2.5);
24 println!("2 + 1 = {}", 3);
25 println!("2 + 1 = {:.4}", 3);
26 println!("2 + 1 = {:5.4}", 3);
27 println!("Debug test {:?}", "hello, world");
29 // positional args don't change the fact
30 // that we're using a literal -- this should
32 println!("{0} {1}", "hello", "world");
33 println!("{1} {0}", "hello", "world");
35 // named args shouldn't change anything either
36 println!("{foo} {bar}", foo="hello", bar="world");
37 println!("{bar} {foo}", foo="hello", bar="world");