MCPcopy Create free account
hub / github.com/CodeSentryAI/lockbud / new

Method new

src/detector/panic/mod.rs:81–100  ·  view source on GitHub ↗
(instance: Instance<'tcx>, tcx: TyCtxt<'tcx>)

Source from the content-addressed store, hash-verified

79
80impl<'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 {

Callers

nothing calls this directly

Calls 1

skip_detectingFunction · 0.85

Tested by

no test coverage detected