| 182 | |
| 183 | impl<'tcx> Visitor<'tcx> for PanicFinder<'tcx> { |
| 184 | fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { |
| 185 | if let TerminatorKind::Call { ref func, .. } = terminator.kind { |
| 186 | let func_ty = func.ty(self.body, self.tcx); |
| 187 | let func_ty = self.instance.instantiate_mir_and_normalize_erasing_regions( |
| 188 | self.tcx, |
| 189 | ty::TypingEnv::fully_monomorphized(), |
| 190 | EarlyBinder::bind(func_ty), |
| 191 | ); |
| 192 | if let TyKind::FnDef(def_id, subst_ref) = func_ty.kind() { |
| 193 | if let Some(callee_instance) = Instance::try_resolve( |
| 194 | self.tcx, |
| 195 | ty::TypingEnv::fully_monomorphized(), |
| 196 | *def_id, |
| 197 | subst_ref, |
| 198 | ) |
| 199 | .ok() |
| 200 | .flatten() |
| 201 | { |
| 202 | if let Some(panic_instance) = PanicInstance::new(callee_instance, self.tcx) { |
| 203 | self.callsites.insert(location, panic_instance); |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | fn skip_detecting<'tcx>(instance: &Instance<'tcx>, tcx: TyCtxt<'tcx>) -> bool { |