@@ -404,34 +404,29 @@ fn visit_fn<'tcx>(
404
404
lsets. warn_about_unused_args ( body, entry_ln) ;
405
405
}
406
406
407
- fn add_from_pat < ' tcx > ( ir : & mut IrMaps < ' tcx > , pat : & P < hir:: Pat > ) {
407
+ fn add_from_pat ( ir : & mut IrMaps < ' _ > , pat : & P < hir:: Pat > ) {
408
408
// For struct patterns, take note of which fields used shorthand
409
409
// (`x` rather than `x: x`).
410
410
let mut shorthand_field_ids = HirIdSet :: default ( ) ;
411
411
let mut pats = VecDeque :: new ( ) ;
412
412
pats. push_back ( pat) ;
413
413
while let Some ( pat) = pats. pop_front ( ) {
414
414
use crate :: hir:: PatKind :: * ;
415
- match pat. node {
416
- Binding ( _ , _ , _ , ref inner_pat) => {
415
+ match & pat. node {
416
+ Binding ( .. , inner_pat) => {
417
417
pats. extend ( inner_pat. iter ( ) ) ;
418
418
}
419
- Struct ( _, ref fields, _) => {
420
- for field in fields {
421
- if field. is_shorthand {
422
- shorthand_field_ids. insert ( field. pat . hir_id ) ;
423
- }
424
- }
419
+ Struct ( _, fields, _) => {
420
+ let ids = fields. iter ( ) . filter ( |f| f. is_shorthand ) . map ( |f| f. pat . hir_id ) ;
421
+ shorthand_field_ids. extend ( ids) ;
425
422
}
426
- Ref ( ref inner_pat, _) |
427
- Box ( ref inner_pat) => {
423
+ Ref ( inner_pat, _) | Box ( inner_pat) => {
428
424
pats. push_back ( inner_pat) ;
429
425
}
430
- TupleStruct ( _, ref inner_pats, _) |
431
- Tuple ( ref inner_pats, _) => {
426
+ TupleStruct ( _, inner_pats, _) | Tuple ( inner_pats, _) | Or ( inner_pats) => {
432
427
pats. extend ( inner_pats. iter ( ) ) ;
433
428
}
434
- Slice ( ref pre_pats, ref inner_pat, ref post_pats) => {
429
+ Slice ( pre_pats, inner_pat, post_pats) => {
435
430
pats. extend ( pre_pats. iter ( ) ) ;
436
431
pats. extend ( inner_pat. iter ( ) ) ;
437
432
pats. extend ( post_pats. iter ( ) ) ;
@@ -440,7 +435,7 @@ fn add_from_pat<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
440
435
}
441
436
}
442
437
443
- pat. each_binding ( |_bm , hir_id, _sp , ident| {
438
+ pat. each_binding ( |_ , hir_id, _ , ident| {
444
439
ir. add_live_node_for_node ( hir_id, VarDefNode ( ident. span ) ) ;
445
440
ir. add_variable ( Local ( LocalInfo {
446
441
id : hir_id,
@@ -456,9 +451,7 @@ fn visit_local<'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local) {
456
451
}
457
452
458
453
fn visit_arm < ' tcx > ( ir : & mut IrMaps < ' tcx > , arm : & ' tcx hir:: Arm ) {
459
- for pat in arm. top_pats_hack ( ) {
460
- add_from_pat ( ir, pat) ;
461
- }
454
+ add_from_pat ( ir, & arm. pat ) ;
462
455
intravisit:: walk_arm ( ir, arm) ;
463
456
}
464
457
0 commit comments