diff options
| author | John Clements <clements@racket-lang.org> | 2014-06-26 13:19:34 -0700 |
|---|---|---|
| committer | John Clements <clements@racket-lang.org> | 2014-06-27 21:41:17 -0700 |
| commit | a18a63185ca79126842d94505746fccef3ade1b8 (patch) | |
| tree | 3fe802e7fde7b548405743a11208d6319b4210d7 /src/libsyntax | |
| parent | 84e8143c4f423011cd337d2a7bfdc54a753eea81 (diff) | |
| download | rust-a18a63185ca79126842d94505746fccef3ade1b8.tar.gz rust-a18a63185ca79126842d94505746fccef3ade1b8.zip | |
WIP match hygiene, compiles
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 073de40382a..c40049a58a7 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -659,15 +659,15 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander) } fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm { - if a.pats.len() == 0 { + if arm.pats.len() == 0 { fail!("encountered match arm with 0 patterns"); } - let first_pat = match a.pats.get(0) { - - } + // all of the pats must have the same set of bindings, so use the + // first one to extract them and generate new names: + let first_pat = arm.pats.get(0); // code duplicated from 'let', above. Perhaps this can be lifted // into a separate function: - let expanded_pat = fld.fold_pat(pat); + let expanded_pat = fld.fold_pat(*first_pat); let mut name_finder = new_name_finder(Vec::new()); name_finder.visit_pat(&*expanded_pat,()); let mut new_pending_renames = Vec::new(); @@ -681,13 +681,13 @@ fn expand_arm(arm: &ast::Arm, fld: &mut MacroExpander) -> ast::Arm { // ones have already been applied): rename_fld.fold_pat(expanded_pat) }; - - let bound_names - ast::Arm { - attrs: a.attrs.iter().map(|x| self.fold_attribute(*x)).collect(), - pats: a.pats.iter().map(|x| self.fold_pat(*x)).collect(), - guard: a.guard.map(|x| self.fold_expr(x)), - body: self.fold_expr(a.body), + /* + */ + ast::Arm { + attrs: arm.attrs.iter().map(|x| fld.fold_attribute(*x)).collect(), + pats: arm.pats.iter().map(|x| fld.fold_pat(*x)).collect(), + guard: arm.guard.map(|x| fld.fold_expr(x)), + body: fld.fold_expr(arm.body), } } |
