]> git.lizzy.rs Git - rust.git/blob - src/test/ui/macros/macro-comma-behavior.rs
Update const_forget.rs
[rust.git] / src / test / ui / macros / macro-comma-behavior.rs
1 // Companion test to the similarly-named file in run-pass.
2
3 // compile-flags: -C debug_assertions=yes
4 // revisions: std core
5
6 #![feature(lang_items)]
7 #![cfg_attr(core, no_std)]
8
9 #[cfg(std)] use std::fmt;
10 #[cfg(core)] use core::fmt;
11 #[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {}
12 #[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {}
13 #[cfg(core)] #[lang = "panic_impl"] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} }
14
15 // (see documentation of the similarly-named test in run-pass)
16 fn to_format_or_not_to_format() {
17     let falsum = || false;
18
19     // assert!(true, "{}",); // see run-pass
20
21     assert_eq!(1, 1, "{}",);
22     //[core]~^ ERROR no arguments
23     //[std]~^^ ERROR no arguments
24     assert_ne!(1, 2, "{}",);
25     //[core]~^ ERROR no arguments
26     //[std]~^^ ERROR no arguments
27
28     // debug_assert!(true, "{}",); // see run-pass
29
30     debug_assert_eq!(1, 1, "{}",);
31     //[core]~^ ERROR no arguments
32     //[std]~^^ ERROR no arguments
33     debug_assert_ne!(1, 2, "{}",);
34     //[core]~^ ERROR no arguments
35     //[std]~^^ ERROR no arguments
36
37     #[cfg(std)] {
38         eprint!("{}",);
39         //[std]~^ ERROR no arguments
40     }
41
42     #[cfg(std)] {
43         // FIXME: compile-fail says "expected error not found" even though
44         //        rustc does emit an error
45         // eprintln!("{}",);
46         // <DISABLED> [std]~^ ERROR no arguments
47     }
48
49     #[cfg(std)] {
50         format!("{}",);
51         //[std]~^ ERROR no arguments
52     }
53
54     format_args!("{}",);
55     //[core]~^ ERROR no arguments
56     //[std]~^^ ERROR no arguments
57
58     // if falsum() { panic!("{}",); } // see run-pass
59
60     #[cfg(std)] {
61         print!("{}",);
62         //[std]~^ ERROR no arguments
63     }
64
65     #[cfg(std)] {
66         // FIXME: compile-fail says "expected error not found" even though
67         //        rustc does emit an error
68         // println!("{}",);
69         // <DISABLED> [std]~^ ERROR no arguments
70     }
71
72     unimplemented!("{}",);
73     //[core]~^ ERROR no arguments
74     //[std]~^^ ERROR no arguments
75
76     // if falsum() { unreachable!("{}",); } // see run-pass
77
78     struct S;
79     impl fmt::Display for S {
80         fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
81             write!(f, "{}",)?;
82             //[core]~^ ERROR no arguments
83             //[std]~^^ ERROR no arguments
84
85             // FIXME: compile-fail says "expected error not found" even though
86             //        rustc does emit an error
87             // writeln!(f, "{}",)?;
88             // <DISABLED> [core]~^ ERROR no arguments
89             // <DISABLED> [std]~^^ ERROR no arguments
90             Ok(())
91         }
92     }
93 }
94
95 fn main() {}