Skip to content

Commit 271c163

Browse files
committed
Fix false-positive debug_assert
1 parent 8f4417f commit 271c163

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/panic_in_result_fn.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::ty::is_type_diagnostic_item;
3-
use clippy_utils::{find_macro_calls, return_ty};
3+
use clippy_utils::{find_macro_calls, is_expn_of, return_ty};
44
use rustc_hir as hir;
55
use rustc_hir::intravisit::FnKind;
66
use rustc_lint::{LateContext, LateLintPass};
@@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {
5252
}
5353

5454
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) {
55-
let panics = find_macro_calls(
55+
let mut panics = find_macro_calls(
5656
&[
5757
"unimplemented",
5858
"unreachable",
@@ -64,6 +64,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir
6464
],
6565
body,
6666
);
67+
panics.retain(|span| is_expn_of(*span, "debug_assert").is_none());
6768
if !panics.is_empty() {
6869
span_lint_and_then(
6970
cx,

0 commit comments

Comments
 (0)