Rollup merge of #98868 - tmiasko:unreachable-coverage, r=wesleywiser
Fix unreachable coverage generation for inlined functions To generate a function coverage we need at least one coverage counter, so a coverage from unreachable blocks is retained only when some live counters remain. The previous implementation incorrectly retained unreachable coverage, because it didn't account for the fact that those live counters can belong to another function due to inlining. Fixes #98833.
This commit is contained in:
@@ -1662,6 +1662,22 @@ impl SourceScope {
|
||||
ClearCrossCrate::Clear => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The instance this source scope was inlined from, if any.
|
||||
#[inline]
|
||||
pub fn inlined_instance<'tcx>(
|
||||
self,
|
||||
source_scopes: &IndexVec<SourceScope, SourceScopeData<'tcx>>,
|
||||
) -> Option<ty::Instance<'tcx>> {
|
||||
let scope_data = &source_scopes[self];
|
||||
if let Some((inlined_instance, _)) = scope_data.inlined {
|
||||
Some(inlined_instance)
|
||||
} else if let Some(inlined_scope) = scope_data.inlined_parent_scope {
|
||||
Some(source_scopes[inlined_scope].inlined.unwrap().0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
|
||||
|
||||
Reference in New Issue
Block a user