Skip to content

Commit 9661f9b

Browse files
authored
Add new condition to avoid derived code trigger lint
1 parent 7c389ac commit 9661f9b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clippy_lints/src/no_effect.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then};
22
use clippy_utils::source::snippet_opt;
33
use clippy_utils::ty::has_drop;
4-
use clippy_utils::{get_parent_node, is_lint_allowed, peel_blocks};
4+
use clippy_utils::{any_parent_is_automatically_derived, get_parent_node, is_lint_allowed, peel_blocks};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::{
@@ -144,6 +144,7 @@ fn check_no_effect(cx: &LateContext<'_>, stmt: &Stmt<'_>) -> bool {
144144
}
145145
} else if let StmtKind::Local(local) = stmt.kind {
146146
if !is_lint_allowed(cx, NO_EFFECT_UNDERSCORE_BINDING, local.hir_id)
147+
&& !any_parent_is_automatically_derived(cx.tcx, local.hir_id)
147148
&& let Some(init) = local.init
148149
&& local.els.is_none()
149150
&& !local.pat.span.from_expansion()

0 commit comments

Comments
 (0)