@@ -121,32 +121,31 @@ fn check_binding_usages<'a>(cx: &LateContext<'a>, body: &Body<'a>, hir_id: HirId
121121 let mut usages: Vec < UsageInfo < ' a > > = Vec :: new ( ) ;
122122
123123 for_each_expr_without_closures ( body. value , |expr| {
124- if let ExprKind :: Path ( ref qpath) = expr. kind {
125- if let Res :: Local ( id) = cx. qpath_res ( qpath, expr. hir_id ) {
126- if id == hir_id {
127- let parent_id = cx. tcx . parent_hir_id ( expr. hir_id ) ;
128- let parent = cx. tcx . hir_node ( parent_id) ;
129-
130- if let rustc_hir:: Node :: Expr ( parent_expr) = parent {
131- if let ExprKind :: Cast ( _, _) = parent_expr. kind {
132- let target_ty = cx. typeck_results ( ) . expr_ty ( parent_expr) ;
133- usages. push ( UsageInfo {
134- is_cast : true ,
135- cast_to : Some ( target_ty) ,
136- } ) ;
137- } else {
138- usages. push ( UsageInfo {
139- is_cast : false ,
140- cast_to : None ,
141- } ) ;
142- }
143- } else {
144- usages. push ( UsageInfo {
145- is_cast : false ,
146- cast_to : None ,
147- } ) ;
148- }
124+ if let ExprKind :: Path ( ref qpath) = expr. kind
125+ && let Res :: Local ( id) = cx. qpath_res ( qpath, expr. hir_id )
126+ && id == hir_id
127+ {
128+ let parent_id = cx. tcx . parent_hir_id ( expr. hir_id ) ;
129+ let parent = cx. tcx . hir_node ( parent_id) ;
130+
131+ if let rustc_hir:: Node :: Expr ( parent_expr) = parent {
132+ if let ExprKind :: Cast ( _, _) = parent_expr. kind {
133+ let target_ty = cx. typeck_results ( ) . expr_ty ( parent_expr) ;
134+ usages. push ( UsageInfo {
135+ is_cast : true ,
136+ cast_to : Some ( target_ty) ,
137+ } ) ;
138+ } else {
139+ usages. push ( UsageInfo {
140+ is_cast : false ,
141+ cast_to : None ,
142+ } ) ;
149143 }
144+ } else {
145+ usages. push ( UsageInfo {
146+ is_cast : false ,
147+ cast_to : None ,
148+ } ) ;
150149 }
151150 }
152151 ControlFlow :: < ( ) > :: Continue ( ( ) )
@@ -160,9 +159,8 @@ fn check_binding_usages<'a>(cx: &LateContext<'a>, body: &Body<'a>, hir_id: HirId
160159 return ;
161160 }
162161
163- let first_target = match usages. first ( ) . and_then ( |u| u. cast_to ) {
164- Some ( ty) => ty,
165- None => return ,
162+ let Some ( first_target) = usages. first ( ) . and_then ( |u| u. cast_to ) else {
163+ return ;
166164 } ;
167165
168166 if !usages. iter ( ) . all ( |u| u. cast_to == Some ( first_target) ) {
0 commit comments