@@ -4,7 +4,7 @@ use rustc_hir::def::Res;
4
4
use rustc_data_structures:: fx:: FxHashMap ;
5
5
use rustc_hir:: { Block , Expr , ExprKind , PatKind , QPath , Stmt , StmtKind } ;
6
6
use rustc_span:: symbol:: { Ident , Symbol } ;
7
- use rustc_middle:: ty:: { Adt , TyS } ;
7
+ use rustc_middle:: ty:: { self , Adt , TyS } ;
8
8
9
9
use rustc_lint:: { LateContext , LateLintPass } ;
10
10
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
@@ -123,7 +123,7 @@ impl LateLintPass<'_> for FieldReassignWithDefault {
123
123
}
124
124
}
125
125
126
- /// Returns the block indices, identifiers and types of bindings set as `Default::default()`.
126
+ /// Returns the block indices, identifiers and types of bindings set as `Default::default()`, except for when the pattern type is a tuple .
127
127
fn enumerate_bindings_using_default < ' cx , ' hir > ( cx : & LateContext < ' cx > , block : & Block < ' hir > ) -> Vec < ( usize , Symbol , & ' cx TyS < ' cx > ) > {
128
128
block
129
129
. stmts
@@ -145,6 +145,10 @@ fn enumerate_bindings_using_default<'cx, 'hir>(cx: &LateContext<'cx>, block: &Bl
145
145
then {
146
146
// Get the type of the pattern
147
147
let ty = cx. typeck_results( ) . pat_ty( local. pat) ;
148
+ // Ignore tuples
149
+ if let ty:: Tuple ( _) = ty. kind( ) {
150
+ return None ;
151
+ }
148
152
Some ( ( idx, ident. name, ty) )
149
153
}
150
154
else {
0 commit comments