@@ -667,19 +667,14 @@ fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm {
667
667
// code duplicated from 'let', above. Perhaps this can be lifted
668
668
// into a separate function:
669
669
let idents = pattern_bindings ( * first_pat) ;
670
- let mut new_pending_renames =
670
+ let new_pending_renames =
671
671
idents. iter ( ) . map ( |id| ( * id, fresh_name ( id) ) ) . collect ( ) ;
672
- // rewrite all of the patterns using the new names (the old
673
- // ones have already been applied). Note that we depend here
674
- // on the guarantee that after expansion, there can't be any
675
- // Path expressions (a.k.a. varrefs) left in the pattern. If
676
- // this were false, we'd need to apply this renaming only to
677
- // the bindings, and not to the varrefs, using a more targeted
678
- // fold-er.
679
- let mut rename_fld = IdentRenamer { renames : & mut new_pending_renames} ;
672
+ // apply the renaming, but only to the PatIdents:
673
+ let mut rename_pats_fld = PatIdentRenamer { renames : & new_pending_renames} ;
680
674
let rewritten_pats =
681
- expanded_pats. iter ( ) . map ( |pat| rename_fld . fold_pat ( * pat) ) . collect ( ) ;
675
+ expanded_pats. iter ( ) . map ( |pat| rename_pats_fld . fold_pat ( * pat) ) . collect ( ) ;
682
676
// apply renaming and then expansion to the guard and the body:
677
+ let mut rename_fld = IdentRenamer { renames : & new_pending_renames} ;
683
678
let rewritten_guard =
684
679
arm. guard . map ( |g| fld. fold_expr ( rename_fld. fold_expr ( g) ) ) ;
685
680
let rewritten_body = fld. fold_expr ( rename_fld. fold_expr ( arm. body ) ) ;
0 commit comments