@@ -404,34 +404,29 @@ fn visit_fn<'tcx>(
404404 lsets. warn_about_unused_args ( body, entry_ln) ;
405405}
406406
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 > ) {
408408 // For struct patterns, take note of which fields used shorthand
409409 // (`x` rather than `x: x`).
410410 let mut shorthand_field_ids = HirIdSet :: default ( ) ;
411411 let mut pats = VecDeque :: new ( ) ;
412412 pats. push_back ( pat) ;
413413 while let Some ( pat) = pats. pop_front ( ) {
414414 use crate :: hir:: PatKind :: * ;
415- match pat. node {
416- Binding ( _ , _ , _ , ref inner_pat) => {
415+ match & pat. node {
416+ Binding ( .. , inner_pat) => {
417417 pats. extend ( inner_pat. iter ( ) ) ;
418418 }
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) ;
425422 }
426- Ref ( ref inner_pat, _) |
427- Box ( ref inner_pat) => {
423+ Ref ( inner_pat, _) | Box ( inner_pat) => {
428424 pats. push_back ( inner_pat) ;
429425 }
430- TupleStruct ( _, ref inner_pats, _) |
431- Tuple ( ref inner_pats, _) => {
426+ TupleStruct ( _, inner_pats, _) | Tuple ( inner_pats, _) | Or ( inner_pats) => {
432427 pats. extend ( inner_pats. iter ( ) ) ;
433428 }
434- Slice ( ref pre_pats, ref inner_pat, ref post_pats) => {
429+ Slice ( pre_pats, inner_pat, post_pats) => {
435430 pats. extend ( pre_pats. iter ( ) ) ;
436431 pats. extend ( inner_pat. iter ( ) ) ;
437432 pats. extend ( post_pats. iter ( ) ) ;
@@ -440,7 +435,7 @@ fn add_from_pat<'tcx>(ir: &mut IrMaps<'tcx>, pat: &P<hir::Pat>) {
440435 }
441436 }
442437
443- pat. each_binding ( |_bm , hir_id, _sp , ident| {
438+ pat. each_binding ( |_ , hir_id, _ , ident| {
444439 ir. add_live_node_for_node ( hir_id, VarDefNode ( ident. span ) ) ;
445440 ir. add_variable ( Local ( LocalInfo {
446441 id : hir_id,
@@ -456,9 +451,7 @@ fn visit_local<'tcx>(ir: &mut IrMaps<'tcx>, local: &'tcx hir::Local) {
456451}
457452
458453fn 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 ) ;
462455 intravisit:: walk_arm ( ir, arm) ;
463456}
464457
0 commit comments