@@ -122,15 +122,8 @@ impl LateLintPass<'_> for Default {
122
122
let mut assigned_fields = Vec :: new ( ) ;
123
123
let mut cancel_lint = false ;
124
124
for consecutive_statement in & block. stmts [ stmt_idx + 1 ..] {
125
- // interrupt if the statement is a let binding (`Local`) that shadows the original
126
- // binding
127
- if stmt_shadows_binding ( consecutive_statement, binding_name) {
128
- break ;
129
- }
130
125
// find out if and which field was set by this `consecutive_statement`
131
- else if let Some ( ( field_ident, assign_rhs) ) =
132
- field_reassigned_by_stmt ( consecutive_statement, binding_name)
133
- {
126
+ if let Some ( ( field_ident, assign_rhs) ) = field_reassigned_by_stmt ( consecutive_statement, binding_name) {
134
127
// interrupt and cancel lint if assign_rhs references the original binding
135
128
if contains_name ( binding_name, assign_rhs) {
136
129
cancel_lint = true ;
@@ -152,7 +145,7 @@ impl LateLintPass<'_> for Default {
152
145
first_assign = Some ( consecutive_statement) ;
153
146
}
154
147
}
155
- // interrupt also if no field was assigned, since we only want to look at consecutive statements
148
+ // interrupt if no field was assigned, since we only want to look at consecutive statements
156
149
else {
157
150
break ;
158
151
}
@@ -256,15 +249,6 @@ fn enumerate_bindings_using_default<'tcx>(
256
249
. collect ( )
257
250
}
258
251
259
- fn stmt_shadows_binding ( this : & Stmt < ' _ > , shadowed : Symbol ) -> bool {
260
- if let StmtKind :: Local ( local) = & this. kind {
261
- if let PatKind :: Binding ( _, _, ident, _) = local. pat . kind {
262
- return ident. name == shadowed;
263
- }
264
- }
265
- false
266
- }
267
-
268
252
/// Returns the reassigned field and the assigning expression (right-hand side of assign).
269
253
fn field_reassigned_by_stmt < ' tcx > ( this : & Stmt < ' tcx > , binding_name : Symbol ) -> Option < ( Ident , & ' tcx Expr < ' tcx > ) > {
270
254
if_chain ! {
0 commit comments