]> git.lizzy.rs Git - rust.git/blob - tests/ui/print.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / print.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
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.
9
10 #![allow(clippy::print_literal, clippy::write_literal)]
11 #![warn(clippy::print_stdout, clippy::use_debug)]
12
13 use std::fmt::{Debug, Display, Formatter, Result};
14
15 #[allow(dead_code)]
16 struct Foo;
17
18 impl Display for Foo {
19     fn fmt(&self, f: &mut Formatter) -> Result {
20         write!(f, "{:?}", 43.1415)
21     }
22 }
23
24 impl Debug for Foo {
25     fn fmt(&self, f: &mut Formatter) -> Result {
26         // ok, we can use `Debug` formatting in `Debug` implementations
27         write!(f, "{:?}", 42.718)
28     }
29 }
30
31 fn main() {
32     println!("Hello");
33     print!("Hello");
34
35     print!("Hello {}", "World");
36
37     print!("Hello {:?}", "World");
38
39     print!("Hello {:#?}", "#orld");
40
41     assert_eq!(42, 1337);
42
43     vec![1, 2];
44 }