]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/macro-comma-behavior.rs
New upstream version 1.26.0+dfsg1
[rustc.git] / src / test / compile-fail / macro-comma-behavior.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Companion test to the similarly-named file in run-pass.
12
13 // compile-flags: -C debug_assertions=yes
14 // revisions: std core
15
16 #![cfg_attr(core, no_std)]
17
18 #[cfg(std)] use std::fmt;
19 #[cfg(core)] use core::fmt;
20
21 // (see documentation of the similarly-named test in run-pass)
22 fn to_format_or_not_to_format() {
23 let falsum = || false;
24
25 // assert!(true, "{}",); // see run-pass
26
27 assert_eq!(1, 1, "{}",);
28 //[core]~^ ERROR no arguments
29 //[std]~^^ ERROR no arguments
30 assert_ne!(1, 2, "{}",);
31 //[core]~^ ERROR no arguments
32 //[std]~^^ ERROR no arguments
33
34 // debug_assert!(true, "{}",); // see run-pass
35
36 debug_assert_eq!(1, 1, "{}",);
37 //[core]~^ ERROR no arguments
38 //[std]~^^ ERROR no arguments
39 debug_assert_ne!(1, 2, "{}",);
40 //[core]~^ ERROR no arguments
41 //[std]~^^ ERROR no arguments
42
43 #[cfg(std)] {
44 eprint!("{}",);
45 //[std]~^ ERROR no arguments
46 }
47
48 #[cfg(std)] {
49 // FIXME: compile-fail says "expected error not found" even though
50 // rustc does emit an error
51 // eprintln!("{}",);
52 // <DISABLED> [std]~^ ERROR no arguments
53 }
54
55 #[cfg(std)] {
56 format!("{}",);
57 //[std]~^ ERROR no arguments
58 }
59
60 format_args!("{}",);
61 //[core]~^ ERROR no arguments
62 //[std]~^^ ERROR no arguments
63
64 // if falsum() { panic!("{}",); } // see run-pass
65
66 #[cfg(std)] {
67 print!("{}",);
68 //[std]~^ ERROR no arguments
69 }
70
71 #[cfg(std)] {
72 // FIXME: compile-fail says "expected error not found" even though
73 // rustc does emit an error
74 // println!("{}",);
75 // <DISABLED> [std]~^ ERROR no arguments
76 }
77
78 unimplemented!("{}",);
79 //[core]~^ ERROR no arguments
80 //[std]~^^ ERROR no arguments
81
82 // if falsum() { unreachable!("{}",); } // see run-pass
83
84 struct S;
85 impl fmt::Display for S {
86 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
87 write!(f, "{}",)?;
88 //[core]~^ ERROR no arguments
89 //[std]~^^ ERROR no arguments
90
91 // FIXME: compile-fail says "expected error not found" even though
92 // rustc does emit an error
93 // writeln!(f, "{}",)?;
94 // <DISABLED> [core]~^ ERROR no arguments
95 // <DISABLED> [std]~^^ ERROR no arguments
96 Ok(())
97 }
98 }
99 }
100
101 fn main() {}