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;
eh_personality()11 #[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {}
12 #[cfg(core)] #[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0;
panic_impl(panic: &core::panic::PanicInfo) -> !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)
to_format_or_not_to_format()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 eprintln!("{}",);
44 //[std]~^ ERROR no arguments
45 }
46
47 #[cfg(std)] {
48 format!("{}",);
49 //[std]~^ ERROR no arguments
50 }
51
52 format_args!("{}",);
53 //[core]~^ ERROR no arguments
54 //[std]~^^ ERROR no arguments
55
56 // if falsum() { panic!("{}",); } // see run-pass
57
58 #[cfg(std)] {
59 print!("{}",);
60 //[std]~^ ERROR no arguments
61 }
62
63 #[cfg(std)] {
64 println!("{}",);
65 //[std]~^ ERROR no arguments
66 }
67
68 unimplemented!("{}",);
69 //[core]~^ ERROR no arguments
70 //[std]~^^ ERROR no arguments
71
72 // if falsum() { unreachable!("{}",); } // see run-pass
73
74 struct S;
75 impl fmt::Display for S {
76 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
77 write!(f, "{}",)?;
78 //[core]~^ ERROR no arguments
79 //[std]~^^ ERROR no arguments
80
81 writeln!(f, "{}",)?;
82 //[core]~^ ERROR no arguments
83 //[std]~^^ ERROR no arguments
84 Ok(())
85 }
86 }
87 }
88
main()89 fn main() {}
90