Skip to content

Commit bdf6eec

Browse files
committed
Address review comments
1 parent a73bf09 commit bdf6eec

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

clippy_lints/src/unit_types/let_unit_value.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,18 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx LetStmt<'_>) {
8282

8383
// If this is a binding pattern, we need to add suggestions to remove any usages
8484
// of the variable
85-
if let PatKind::Binding(_, binding_hir_id, ident, ..) = local.pat.kind {
86-
if let Some(body_id) = cx.enclosing_body.as_ref() {
87-
let body = cx.tcx.hir().body(*body_id);
88-
89-
// Collect variable usages
90-
let mut visitor = UnitVariableCollector::new(binding_hir_id);
91-
walk_body(&mut visitor, body);
92-
93-
// Add suggestions for replacing variable usages
94-
let has_usages = !visitor.spans.is_empty();
95-
if has_usages {
96-
suggestions.extend(visitor.spans.into_iter().map(|span| (span, "()".to_string())));
97-
}
98-
}
85+
if let PatKind::Binding(_, binding_hir_id, ident, ..) = local.pat.kind
86+
&& let Some(body_id) = cx.enclosing_body.as_ref()
87+
{
88+
let body = cx.tcx.hir().body(*body_id);
89+
90+
// Collect variable usages
91+
let mut visitor = UnitVariableCollector::new(binding_hir_id);
92+
walk_body(&mut visitor, body);
93+
94+
// Add suggestions for replacing variable usages
95+
let has_usages = !visitor.spans.is_empty();
96+
suggestions.extend(visitor.spans.into_iter().map(|span| (span, "()".to_string())));
9997
}
10098

10199
// Emit appropriate diagnostic based on whether there are usages of the let binding

0 commit comments

Comments
 (0)