Skip to content

Commit a18a631

Browse files
committed
WIP match hygiene, compiles
1 parent 84e8143 commit a18a631

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -659,15 +659,15 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
659659
}
660660

661661
fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm {
662-
if a.pats.len() == 0 {
662+
if arm.pats.len() == 0 {
663663
fail!("encountered match arm with 0 patterns");
664664
}
665-
let first_pat = match a.pats.get(0) {
666-
667-
}
665+
// all of the pats must have the same set of bindings, so use the
666+
// first one to extract them and generate new names:
667+
let first_pat = arm.pats.get(0);
668668
// code duplicated from 'let', above. Perhaps this can be lifted
669669
// into a separate function:
670-
let expanded_pat = fld.fold_pat(pat);
670+
let expanded_pat = fld.fold_pat(*first_pat);
671671
let mut name_finder = new_name_finder(Vec::new());
672672
name_finder.visit_pat(&*expanded_pat,());
673673
let mut new_pending_renames = Vec::new();
@@ -681,13 +681,13 @@ fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm {
681681
// ones have already been applied):
682682
rename_fld.fold_pat(expanded_pat)
683683
};
684-
685-
let bound_names
686-
ast::Arm {
687-
attrs: a.attrs.iter().map(|x| self.fold_attribute(*x)).collect(),
688-
pats: a.pats.iter().map(|x| self.fold_pat(*x)).collect(),
689-
guard: a.guard.map(|x| self.fold_expr(x)),
690-
body: self.fold_expr(a.body),
684+
/*
685+
*/
686+
ast::Arm {
687+
attrs: arm.attrs.iter().map(|x| fld.fold_attribute(*x)).collect(),
688+
pats: arm.pats.iter().map(|x| fld.fold_pat(*x)).collect(),
689+
guard: arm.guard.map(|x| fld.fold_expr(x)),
690+
body: fld.fold_expr(arm.body),
691691
}
692692
}
693693

0 commit comments

Comments
 (0)