@@ -82,20 +82,18 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, local: &'tcx LetStmt<'_>) {
82
82
83
83
// If this is a binding pattern, we need to add suggestions to remove any usages
84
84
// 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 ( ) ) ) ) ;
99
97
}
100
98
101
99
// Emit appropriate diagnostic based on whether there are usages of the let binding
0 commit comments