about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/coverageinfo
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-16 13:38:39 +0000
committerbors <bors@rust-lang.org>2024-07-16 13:38:39 +0000
commit216bef36bccb67bcc4c0a4d7940f6dc84c4fac7b (patch)
tree11e65227b6348995609411f581e100f97e9475b6 /compiler/rustc_codegen_llvm/src/coverageinfo
parente5b1a2b3cd1e3a53b939e81a3eef1f4da924eb0f (diff)
parent137c736d667dd500ddac47450df21ae9be345ba0 (diff)
downloadrust-216bef36bccb67bcc4c0a4d7940f6dc84c4fac7b.tar.gz
rust-216bef36bccb67bcc4c0a4d7940f6dc84c4fac7b.zip
Auto merge of #17609 - lnicola:sync-from-rust, r=lnicola
minor: Sync from downstream
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo')
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
index b969fe27a99..14a94468587 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs
@@ -66,8 +66,15 @@ impl<'tcx> FunctionCoverageCollector<'tcx> {
         // For each expression ID that is directly used by one or more mappings,
         // mark it as not-yet-seen. This indicates that we expect to see a
         // corresponding `ExpressionUsed` statement during MIR traversal.
-        for term in function_coverage_info.mappings.iter().flat_map(|m| m.kind.terms()) {
-            if let CovTerm::Expression(id) = term {
+        for mapping in function_coverage_info.mappings.iter() {
+            // Currently we only worry about ordinary code mappings.
+            // For branch and MC/DC mappings, expressions might not correspond
+            // to any particular point in the control-flow graph.
+            // (Keep this in sync with the injection of `ExpressionUsed`
+            // statements in the `InstrumentCoverage` MIR pass.)
+            if let MappingKind::Code(term) = mapping.kind
+                && let CovTerm::Expression(id) = term
+            {
                 expressions_seen.remove(id);
             }
         }