1 1| |// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
3 3| |// expect-exit-status-101
4 4| 21|#[derive(PartialEq, Eq)]
6 | <issue_84561::Foo as core::cmp::PartialEq>::eq:
7 | 4| 21|#[derive(PartialEq, Eq)]
9 | Unexecuted instantiation: <issue_84561::Foo as core::cmp::PartialEq>::ne
13 7| 1| let is_true = std::env::args().len() == 1;
14 8| 1| let bar = Foo(1);
15 9| 1| assert_eq!(bar, Foo(1));
16 10| 1| let baz = Foo(0);
17 11| 1| assert_ne!(baz, Foo(1));
18 12| 1| println!("{:?}", Foo(1));
19 13| 1| println!("{:?}", bar);
20 14| 1| println!("{:?}", baz);
22 16| 1| assert_eq!(Foo(1), Foo(1));
23 17| 1| assert_ne!(Foo(0), Foo(1));
24 18| 1| assert_eq!(Foo(2), Foo(2));
25 19| 1| let bar = Foo(0);
26 20| 1| assert_ne!(bar, Foo(3));
27 21| 1| assert_ne!(Foo(0), Foo(4));
28 22| 1| assert_eq!(Foo(3), Foo(3), "with a message");
30 23| 1| println!("{:?}", bar);
31 24| 1| println!("{:?}", Foo(1));
33 26| 1| assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" });
47 39| 0| "false message"
51 43| 1| let is_true = std::env::args().len() == 1;
65 57| 1| let bar = Foo(1);
85 77| 0| "with a message"
91 83| 0| "with a message"
129 121| 0| "with a message"
134 126| 1| "this assert should fail"
139 131| 0| "this assert should not be reached"
143 135| |impl std::fmt::Debug for Foo {
144 136| | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
145 137| 7| write!(f, "try and succeed")?;
151 142| |static mut DEBUG_LEVEL_ENABLED: bool = false;
153 144| |macro_rules! debug {
154 145| | ($($arg:tt)+) => (
155 146| | if unsafe { DEBUG_LEVEL_ENABLED } {
156 147| | println!($($arg)+);
162 153| 1| debug!("debug is enabled");
164 154| 1| debug!("debug is enabled");
167 156| 1| debug!("debug is enabled");
170 158| 1| DEBUG_LEVEL_ENABLED = true;
172 160| 1| debug!("debug is enabled");
175 163| |macro_rules! call_debug {
176 164| | ($($arg:tt)+) => (
177 165| 1| fn call_print(s: &str) {
178 166| 1| print!("{}", s);
181 169| | call_print("called from call_debug: ");
182 170| | debug!($($arg)+);
187 175| 1| call_debug!("debug is enabled");