granite-rust/compiler
Rich Kadel cb70221857 Coverage instruments closure bodies in macros (not the macro body)
Fixes: #84884

This solution might be considered a compromise, but I think it is the
better choice.

The results in the `closure.rs` test correctly resolve all test cases
broken as described in #84884.

One test pattern (in both `closure_macro.rs` and
`closure_macro_async.rs`) was also affected, and removes coverage
statistics for the lines inside the closure, because the closure
includes a macro. (The coverage remains at the callsite of the macro, so
we lose some detail, but there isn't a perfect choice with macros.

Often macro implementations are split across the macro and the callsite,
and there doesn't appear to be a single "right choice" for which body
should be covered. For the current implementation, we can't do both.

The callsite is most likely to be the preferred site for coverage.

I applied this fix to all `MacroKinds`, not just `Bang`.

I'm trying to resolve an issue of lost coverage in a
`MacroKind::Attr`-based, function-scoped macro. Instead of only
searching for a body_span that is "not a function-like macro" (that is,
MacroKind::Bang), I'm expanding this to all `MacroKind`s. Maybe I should
expand this to `ExpnKind::Desugaring` and `ExpnKind::AstPass` (or
subsets, depending on their sub-kinds) as well, but I'm not sure that's
a good idea.

I'd like to add a test of the `Attr` macro on functions, but I need time
to figure out how to constract a good, simple example without external
crate dependencies. For the moment, all tests still work as expected (no
change), this new commit shouldn't have a negative affect, and more
importantly, I believe it will have a positive effect. I will try to
confirm this.
2021-05-06 11:15:39 -07:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakis 2021-04-28 20:35:17 +00:00
rustc_ast_lowering Lower async fn in traits. 2021-04-13 20:57:44 +02:00
rustc_ast_passes Auto merge of #83713 - spastorino:revert-pub-macro-rules, r=nikomatsakis 2021-04-28 05:52:47 +00:00
rustc_ast_pretty Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
rustc_attr Allow specifying alignment for functions 2021-04-05 17:36:51 -04:00
rustc_builtin_macros adds feature gating of no_coverage at either crate- or function-level 2021-04-27 17:12:51 -07:00
rustc_codegen_cranelift Merge commit '15c8d31392b9fbab3b3368b67acc4bbe5983115a' into cranelift-rebase 2021-04-30 18:46:59 +02:00
rustc_codegen_llvm Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_codegen_ssa Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_data_structures Auto merge of #84614 - RalfJung:daily, r=Mark-Simulacrum 2021-04-29 02:53:52 +00:00
rustc_driver Rollup merge of #83895 - eggyal:issue-83883, r=jyn514 2021-04-06 17:42:31 +02:00
rustc_error_codes Implement RFC 1260 with feature_name imported_main. 2021-04-29 08:35:08 +08:00
rustc_errors Rollup merge of #84235 - klensy:styled-buffer, r=lcnr 2021-04-25 23:15:10 +02:00
rustc_expand Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_feature Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_fs_util Optimize away a fs::metadata call. 2021-01-06 08:33:15 -08:00
rustc_graphviz Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_hir Auto merge of #84299 - lcnr:const-generics-defaults-name-res, r=varkor 2021-04-25 14:00:49 +00:00
rustc_hir_pretty Handle pretty printing of else if let clauses 2021-04-23 13:29:18 -04:00
rustc_incremental Add [TRACKED_NO_CRATE_HASH] and [SUBSTRUCT] directives 2021-04-27 16:46:33 +00:00
rustc_index fix sanitizer tests 2021-04-25 11:08:33 +02:00
rustc_infer Don't rebind in transitive_bounds_that_define_assoc_type 2021-04-28 18:10:44 -04:00
rustc_interface Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_lexer Fix outdated crate names in compiler docs 2021-04-08 11:12:14 -05:00
rustc_lint Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakis 2021-04-28 20:35:17 +00:00
rustc_lint_defs Typo 2021-04-20 09:30:28 -04:00
rustc_llvm Replace llvm::sys::fs::F_None with llvm::sys::fs::OF_None 2021-04-29 15:25:17 -07:00
rustc_macros Use iter::zip in compiler/ 2021-03-26 09:32:31 -07:00
rustc_metadata Make real_rust_path_dir a TRACKED_NO_CRATE_HASH option 2021-04-27 16:48:25 +00:00
rustc_middle Auto merge of #84719 - Mark-Simulacrum:reduce-query-impl, r=davidtwco 2021-04-30 22:21:07 +00:00
rustc_mir Coverage instruments closure bodies in macros (not the macro body) 2021-05-06 11:15:39 -07:00
rustc_mir_build Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk 2021-04-24 23:16:03 +00:00
rustc_parse Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakis 2021-04-28 20:35:17 +00:00
rustc_parse_format Rollup merge of #83348 - osa1:issue83344, r=jackh726 2021-03-28 01:33:13 +09:00
rustc_passes Implement RFC 1260 with feature_name imported_main. 2021-04-29 08:35:08 +08:00
rustc_plugin_impl Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
rustc_privacy fix few typos 2021-04-19 15:57:08 +03:00
rustc_query_impl Move iter_results to dyn FnMut rather than a generic 2021-04-29 17:26:46 -04:00
rustc_query_system Move iter_results to dyn FnMut rather than a generic 2021-04-29 17:26:46 -04:00
rustc_resolve Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_save_analysis Remove hir::CrateItem. 2021-03-30 20:31:06 +02:00
rustc_serialize Auto merge of #83465 - michaelwoerister:safe-read_raw_bytes, r=cjgillot 2021-03-26 01:28:59 +00:00
rustc_session Use doc-comment instad of comments consistently 2021-04-29 12:53:49 +00:00
rustc_span Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00
rustc_symbol_mangling Rollup merge of #80525 - devsnek:wasm64, r=nagisa 2021-04-05 00:24:23 +02:00
rustc_target Auto merge of #84658 - Amanieu:reserved_regs, r=petrochenkov 2021-05-01 13:01:24 +00:00
rustc_trait_selection Make traits with GATs not object safe 2021-04-27 14:34:23 -04:00
rustc_traits Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_ty_utils move representability out of rustc_middle 2021-04-27 15:01:37 +02:00
rustc_type_ir Remove nightly features in rustc_type_ir 2021-04-03 10:00:09 +02:00
rustc_typeck Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkov 2021-04-30 06:59:37 +00:00