@@ -249,9 +249,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
249
249
None
250
250
}
251
251
252
- fn is_hir_id_from_struct_pattern_shorthand_field ( & self , hir_id : hir:: HirId ) -> bool {
253
- let parent_id = self . tcx . hir ( ) . get_parent_node_by_hir_id ( expr . hir_id ) ;
254
- let mut is_struct_pat_shorthand_field = false ;
252
+ fn is_hir_id_from_struct_pattern_shorthand_field ( & self , hir_id : hir:: HirId , sp : Span ) -> bool {
253
+ let cm = self . sess ( ) . source_map ( ) ;
254
+ let parent_id = self . tcx . hir ( ) . get_parent_node_by_hir_id ( hir_id ) ;
255
255
if let Some ( parent) = self . tcx . hir ( ) . find_by_hir_id ( parent_id) {
256
256
// Account for fields
257
257
if let Node :: Expr ( hir:: Expr {
@@ -260,13 +260,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
260
260
if let Ok ( src) = cm. span_to_snippet ( sp) {
261
261
for field in fields {
262
262
if field. ident . as_str ( ) == src. as_str ( ) && field. is_shorthand {
263
- is_struct_pat_shorthand_field = true ;
264
- break ;
263
+ return true ;
265
264
}
266
265
}
267
266
}
268
267
}
269
- } ;
268
+ }
269
+ false
270
270
}
271
271
272
272
/// This function is used to determine potential "simple" improvements or users' errors and
@@ -297,8 +297,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
297
297
return None ;
298
298
}
299
299
300
- let mut is_struct_pat_shorthand_field =
301
- self . is_hir_id_from_struct_pattern_shorthand_field ( expr. hir_id ) ;
300
+ let is_struct_pat_shorthand_field = self . is_hir_id_from_struct_pattern_shorthand_field (
301
+ expr. hir_id ,
302
+ sp,
303
+ ) ;
302
304
303
305
match ( & expected. sty , & checked_ty. sty ) {
304
306
( & ty:: Ref ( _, exp, _) , & ty:: Ref ( _, check, _) ) => match ( & exp. sty , & check. sty ) {
0 commit comments