]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/print.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / print.rs
1
2
3 #![allow(print_literal, write_literal)]
4 #![warn(print_stdout, use_debug)]
5
6 use std::fmt::{Debug, Display, Formatter, Result};
7
8 #[allow(dead_code)]
9 struct Foo;
10
11 impl Display for Foo {
12 fn fmt(&self, f: &mut Formatter) -> Result {
13 write!(f, "{:?}", 43.1415)
14 }
15 }
16
17 impl Debug for Foo {
18 fn fmt(&self, f: &mut Formatter) -> Result {
19 // ok, we can use `Debug` formatting in `Debug` implementations
20 write!(f, "{:?}", 42.718)
21 }
22 }
23
24 fn main() {
25 println!("Hello");
26 print!("Hello");
27
28 print!("Hello {}", "World");
29
30 print!("Hello {:?}", "World");
31
32 print!("Hello {:#?}", "#orld");
33
34 assert_eq!(42, 1337);
35
36 vec![1, 2];
37 }