From 2f81e4e34f96ee674072cbd1ffe55b68da5cc425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Sun, 4 Apr 2021 13:03:05 +0200 Subject: [PATCH] modification not working: fixing --- clippy_lints/src/doc.rs | 5 +++++ clippy_utils/src/lib.rs | 2 -- clippy_utils/src/paths.rs | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 69800f9d331..ea4f4fda0dd 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -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(); diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index aade3409ebe..d6364625e70 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -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 diff --git a/clippy_utils/src/paths.rs b/clippy_utils/src/paths.rs index 287da83babd..7c83a9fe4e2 100644 --- a/clippy_utils/src/paths.rs +++ b/clippy_utils/src/paths.rs @@ -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"];