]> git.lizzy.rs Git - rust.git/blob - tests/ui/print.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / print.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3 #![deny(print_stdout, use_debug)]
4
5 use std::fmt::{Debug, Display, Formatter, Result};
6
7 #[allow(dead_code)]
8 struct Foo;
9
10 impl Display for Foo {
11     fn fmt(&self, f: &mut Formatter) -> Result {
12         write!(f, "{:?}", 43.1415)
13         //~^ ERROR use of `Debug`-based formatting
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"); //~ERROR use of `println!`
26     print!("Hello"); //~ERROR use of `print!`
27
28     print!("Hello {}", "World"); //~ERROR use of `print!`
29
30     print!("Hello {:?}", "World");
31     //~^ ERROR use of `print!`
32     //~| ERROR use of `Debug`-based formatting
33
34     print!("Hello {:#?}", "#orld");
35     //~^ ERROR use of `print!`
36     //~| ERROR use of `Debug`-based formatting
37
38     assert_eq!(42, 1337);
39
40     vec![1, 2];
41 }