1
Fork 0

coverage: Add branch coverage support for if-let and let-chains

This commit is contained in:
Zalathar 2024-04-17 11:41:41 +10:00
parent c9dd07dd5e
commit 7c87ad0430
4 changed files with 29 additions and 8 deletions

View file

@ -200,7 +200,7 @@ impl<'tcx> Builder<'_, 'tcx> {
/// If branch coverage is enabled, inject marker statements into `true_block`
/// and `false_block`, and record their IDs in the table of branches.
///
/// Used to instrument let-else for branch coverage.
/// Used to instrument let-else and if-let (including let-chains) for branch coverage.
pub(crate) fn visit_coverage_conditional_let(
&mut self,
pattern: &Pat<'tcx>, // Pattern that has been matched when the true path is taken

View file

@ -1968,6 +1968,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
false,
);
// If branch coverage is enabled, record this branch.
self.visit_coverage_conditional_let(pat, post_guard_block, otherwise_post_guard_block);
post_guard_block.unit()
}