mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Add SourceScope::inlined_instance
This commit is contained in:
parent
eba361ae36
commit
7e7d007467
@ -9,11 +9,8 @@ use super::FunctionCx;
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
pub fn codegen_coverage(&self, bx: &mut Bx, coverage: Coverage, scope: SourceScope) {
|
||||
// Determine the instance that coverage data was originally generated for.
|
||||
let scope_data = &self.mir.source_scopes[scope];
|
||||
let instance = if let Some((inlined_instance, _)) = scope_data.inlined {
|
||||
self.monomorphize(inlined_instance)
|
||||
} else if let Some(inlined_scope) = scope_data.inlined_parent_scope {
|
||||
self.monomorphize(self.mir.source_scopes[inlined_scope].inlined.unwrap().0)
|
||||
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
|
||||
self.monomorphize(inlined)
|
||||
} else {
|
||||
self.instance
|
||||
};
|
||||
|
@ -1650,6 +1650,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)]
|
||||
|
Loading…
Reference in New Issue
Block a user