diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-02-07 17:28:07 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-02-11 16:55:24 -0500 |
| commit | ec6d122826cf00ace0dbbcb82f36dc92b2a1df83 (patch) | |
| tree | 1014efa609f51ac1020acb01ce82ef91c4935498 /src/libsyntax/ext | |
| parent | e3ca1c2fcac616d796c648b87bddd5acfb11bdda (diff) | |
| download | rust-ec6d122826cf00ace0dbbcb82f36dc92b2a1df83.tar.gz rust-ec6d122826cf00ace0dbbcb82f36dc92b2a1df83.zip | |
libsyntax -- combine two iter ops into one so that `fld` does not need to be mutably shared between them both
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 69611829c7c..d146cd4dae3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -709,14 +709,15 @@ pub fn expand_block(blk: &Block, fld: &mut MacroExpander) -> P<Block> { // expand the elements of a block. pub fn expand_block_elts(b: &Block, fld: &mut MacroExpander) -> P<Block> { let new_view_items = b.view_items.map(|x| fld.fold_view_item(x)); - let new_stmts = b.stmts.iter() - .map(|x| { + let new_stmts = + b.stmts.iter().flat_map(|x| { + let renamed_stmt = { let pending_renames = &mut fld.extsbox.info().pending_renames; let mut rename_fld = renames_to_fold(pending_renames); rename_fld.fold_stmt(*x).expect_one("rename_fold didn't return one value") - }) - .flat_map(|x| fld.fold_stmt(x).move_iter()) - .collect(); + }; + fld.fold_stmt(renamed_stmt).move_iter() + }).collect(); let new_expr = b.expr.map(|x| { let expr = { let pending_renames = &mut fld.extsbox.info().pending_renames; |
