(instance: Instance<'tcx>, tcx: TyCtxt<'tcx>)
| 79 | |
| 80 | impl<'tcx> PanicInstance<'tcx> { |
| 81 | fn new(instance: Instance<'tcx>, tcx: TyCtxt<'tcx>) -> Option<Self> { |
| 82 | let def_path_str = tcx.def_path_str_with_args(instance.def_id(), instance.args); |
| 83 | if PANIC_API_REGEX[&PanicAPI::ResultUnwrap].is_match(&def_path_str) { |
| 84 | Some(PanicInstance::ResultUnwrap(instance)) |
| 85 | } else if PANIC_API_REGEX[&PanicAPI::ResultExpect].is_match(&def_path_str) { |
| 86 | Some(PanicInstance::ResultExpect(instance)) |
| 87 | } else if PANIC_API_REGEX[&PanicAPI::OptionUnwrap].is_match(&def_path_str) { |
| 88 | Some(PanicInstance::OptionUnwrap(instance)) |
| 89 | } else if PANIC_API_REGEX[&PanicAPI::OptionExpect].is_match(&def_path_str) { |
| 90 | Some(PanicInstance::OptionExpect(instance)) |
| 91 | } else if PANIC_API_REGEX[&PanicAPI::PanicFmt].is_match(&def_path_str) { |
| 92 | Some(PanicInstance::PanicFmt(instance)) |
| 93 | } else if PANIC_API_REGEX[&PanicAPI::AssertFailed].is_match(&def_path_str) { |
| 94 | Some(PanicInstance::AssertFailed(instance)) |
| 95 | } else if PANIC_API_REGEX[&PanicAPI::Panic].is_match(&def_path_str) { |
| 96 | Some(PanicInstance::Panic(instance)) |
| 97 | } else { |
| 98 | None |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | fn to_panic_api(&self) -> PanicAPI { |
| 103 | match self { |
nothing calls this directly
no test coverage detected