(
tcx: TyCtxt<'tcx>,
caller: Instance<'tcx>,
callee: &str,
location: Option<&super::dwarf::Location>,
)
| 78 | } |
| 79 | |
| 80 | pub fn recover_fn_call_span<'tcx>( |
| 81 | tcx: TyCtxt<'tcx>, |
| 82 | caller: Instance<'tcx>, |
| 83 | callee: &str, |
| 84 | location: Option<&super::dwarf::Location>, |
| 85 | ) -> Option<(Instance<'tcx>, UseSiteKind)> { |
| 86 | let mir = tcx.instance_mir(caller.def); |
| 87 | |
| 88 | let mut callee_instance = None; |
| 89 | let mut sites = Vec::new(); |
| 90 | |
| 91 | for block in mir.basic_blocks.iter() { |
| 92 | let terminator = block.terminator(); |
| 93 | |
| 94 | // Skip over inlined body. We'll check them from scopes directly. |
| 95 | if mir.source_scopes[terminator.source_info.scope] |
| 96 | .inlined |
| 97 | .is_some() |
| 98 | { |
| 99 | continue; |
| 100 | } |
| 101 | |
| 102 | match terminator.kind { |
| 103 | mir::TerminatorKind::Call { ref func, .. } |
| 104 | | mir::TerminatorKind::TailCall { ref func, .. } => { |
| 105 | let callee_ty = func.ty(mir, tcx); |
| 106 | let callee_ty = caller.instantiate_mir_and_normalize_erasing_regions( |
| 107 | tcx, |
| 108 | ty::TypingEnv::fully_monomorphized(), |
| 109 | ty::EarlyBinder::bind(callee_ty), |
| 110 | ); |
| 111 | |
| 112 | let ty::FnDef(def_id, args) = *callee_ty.kind() else { |
| 113 | continue; |
| 114 | }; |
| 115 | |
| 116 | let instance = ty::Instance::expect_resolve( |
| 117 | tcx, |
| 118 | ty::TypingEnv::fully_monomorphized(), |
| 119 | def_id, |
| 120 | args, |
| 121 | terminator.source_info.span, |
| 122 | ); |
| 123 | if tcx.symbol_name(instance).name != callee { |
| 124 | continue; |
| 125 | } |
| 126 | |
| 127 | callee_instance = Some(instance); |
| 128 | sites.push(UseSiteKind::Call(terminator.source_info.span)); |
| 129 | } |
| 130 | mir::TerminatorKind::Drop { ref place, .. } => { |
| 131 | let ty = place.ty(mir, tcx).ty; |
| 132 | let ty = caller.instantiate_mir_and_normalize_erasing_regions( |
| 133 | tcx, |
| 134 | ty::TypingEnv::fully_monomorphized(), |
| 135 | ty::EarlyBinder::bind(ty), |
| 136 | ); |
| 137 |
no test coverage detected