Description
I expect something that looks like the result, for a similar (non-macro) closure:
131| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
^0
But instead we get results like the following:
135| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called");
136| 1| let _short_unused_closure = | _unused_arg: u8 | println!("not called");
...
170| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch =
171| | | _unused_arg: u8 |
172| | println!(
173| | "not called: {}",
174| | if is_true { "check" } else { "me" }
175| | )
176| | ;
177| 1| if is_false {
178| 0| short_used_not_covered_closure_macro(0);
179| 0| short_used_not_covered_closure_line_break_no_block_embedded_branch(0);
180| 1| }
This issue is demonstrated in the coverage results from the test: https://github.com/rust-lang/rust/blob/031c756d16290f3f8ed25a64126ff82cca17123d/src/test/run-make/coverage/closure.rs#L136
I have a new PR in progress to show more examples, and those examples expose the fact that the coverage for println!(...)
is actually being added to the macro's source itself.
Note that there were 5 println!(...)
macro calls with missing coverage in the corresponding test case, and the coverage report shows 5 Unexecuted instantiations
. So all are taken into account.
Nevertheless, this is a function-like macro, and it should behave like a function call, and show the coverage at the calling site.
/usr/local/google/home/richkadel/rust/library/std/src/macros.rs:
94| |macro_rules! println {
95| | () => ($crate::print!("\n"));
96| 0| ($($arg:tt)*) => ({
97| 0| $crate::io::_print($crate::format_args_nl!($($arg)*));
------------------
| Unexecuted instantiation: closure::main::{closure#13}
------------------
98| 0| })
------------------
| Unexecuted instantiation: closure::main::{closure#5}
------------------
| Unexecuted instantiation: closure::main::{closure#12}
------------------
| Unexecuted instantiation: closure::main::{closure#6}
------------------
| Unexecuted instantiation: closure::main::{closure#11}
------------------
99| |}