modification not working: fixing

This commit is contained in:
Aliénore Bouttefeux 2021-04-04 13:03:05 +02:00
parent 984ab98712
commit 2f81e4e34f
3 changed files with 5 additions and 3 deletions

View file

@ -721,6 +721,11 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
}
}
// check for `assert_eq` or `assert_ne`
if is_expn_of(expr.span, "assert_eq").is_some() || is_expn_of(expr.span, "assert_ne").is_some() {
self.panic_span = Some(expr.span);
}
// check for `unwrap`
if let Some(arglists) = method_chain_args(expr, &["unwrap"]) {
let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();

View file

@ -1172,7 +1172,6 @@ pub fn match_panic_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> O
.or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC))
.or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC_FMT))
.or_else(|| match_function_call(cx, expr, &paths::PANICKING_PANIC_STR))
.or_else(|| match_function_call(cx, expr, &paths::PANICKING_ASSERT_FAILED_INNER))
}
pub fn match_panic_def_id(cx: &LateContext<'_>, did: DefId) -> bool {
@ -1182,7 +1181,6 @@ pub fn match_panic_def_id(cx: &LateContext<'_>, did: DefId) -> bool {
|| match_def_path(cx, did, &paths::PANICKING_PANIC)
|| match_def_path(cx, did, &paths::PANICKING_PANIC_FMT)
|| match_def_path(cx, did, &paths::PANICKING_PANIC_STR)
|| match_def_path(cx, did, &paths::PANICKING_ASSERT_FAILED_INNER)
}
/// Returns the list of condition expressions and the list of blocks in a

View file

@ -86,7 +86,6 @@ pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"];
pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
pub(super) const PANICKING_ASSERT_FAILED_INNER: [&str; 3] = ["core", "panicking", "assert_failed_inner"];
pub(super) const PANICKING_PANIC: [&str; 3] = ["core", "panicking", "panic"];
pub(super) const PANICKING_PANIC_FMT: [&str; 3] = ["core", "panicking", "panic_fmt"];
pub(super) const PANICKING_PANIC_STR: [&str; 3] = ["core", "panicking", "panic_str"];