Skip to content

Commit

Permalink
libsyntax -- combine two iter ops into one so that fld does not nee…
Browse files Browse the repository at this point in the history
…d to be mutably shared between them both
  • Loading branch information
nikomatsakis committed Feb 11, 2014
1 parent e3ca1c2 commit ec6d122
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ec6d122

Please sign in to comment.