Skip to content

Commit 6bee3c8

Browse files
committed
use PatIdentRenamer for match bindings
1 parent 35175f0 commit 6bee3c8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,19 +667,14 @@ fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm {
667667
// code duplicated from 'let', above. Perhaps this can be lifted
668668
// into a separate function:
669669
let idents = pattern_bindings(*first_pat);
670-
let mut new_pending_renames =
670+
let new_pending_renames =
671671
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};
680674
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();
682676
// apply renaming and then expansion to the guard and the body:
677+
let mut rename_fld = IdentRenamer{renames:&new_pending_renames};
683678
let rewritten_guard =
684679
arm.guard.map(|g| fld.fold_expr(rename_fld.fold_expr(g)));
685680
let rewritten_body = fld.fold_expr(rename_fld.fold_expr(arm.body));

0 commit comments

Comments
 (0)