Skip to content

Commit

Permalink
Fix false-positive debug_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Apr 10, 2021
1 parent 8f4417f commit 271c163
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clippy_lints/src/panic_in_result_fn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::ty::is_type_diagnostic_item;
use clippy_utils::{find_macro_calls, return_ty};
use clippy_utils::{find_macro_calls, is_expn_of, return_ty};
use rustc_hir as hir;
use rustc_hir::intravisit::FnKind;
use rustc_lint::{LateContext, LateLintPass};
Expand Down Expand Up @@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {
}

fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) {
let panics = find_macro_calls(
let mut panics = find_macro_calls(
&[
"unimplemented",
"unreachable",
Expand All @@ -64,6 +64,7 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir
],
body,
);
panics.retain(|span| is_expn_of(*span, "debug_assert").is_none());
if !panics.is_empty() {
span_lint_and_then(
cx,
Expand Down

0 comments on commit 271c163

Please sign in to comment.