let make_call = |lctx: &LoweringContext, p, args| {
let path = core_path(lctx, e.span, p);
- let path = expr_path(lctx, path);
- expr_call(lctx, e.span, path, args)
+ let path = expr_path(lctx, path, None);
+ expr_call(lctx, e.span, path, args, None)
};
let mk_stmt_let = |lctx: &LoweringContext, bind, expr| {
- stmt_let(lctx, e.span, false, bind, expr)
+ stmt_let(lctx, e.span, false, bind, expr, None)
};
let mk_stmt_let_mut = |lctx: &LoweringContext, bind, expr| {
- stmt_let(lctx, e.span, true, bind, expr)
+ stmt_let(lctx, e.span, true, bind, expr, None)
};
// let placer = <placer_expr> ;
vec![],
placer_expr,
e.span,
- hir::PopUnstableBlock);
+ hir::PopUnstableBlock,
+ None);
mk_stmt_let(lctx, placer_ident, placer_expr)
};
// let mut place = Placer::make_place(placer);
let s2 = {
- let placer = expr_ident(lctx, e.span, placer_ident);
+ let placer = expr_ident(lctx, e.span, placer_ident, None);
let call = make_call(lctx, &make_place, vec![placer]);
mk_stmt_let_mut(lctx, place_ident, call)
};
// let p_ptr = Place::pointer(&mut place);
let s3 = {
- let agent = expr_ident(lctx, e.span, place_ident);
- let args = vec![expr_mut_addr_of(lctx, e.span, agent)];
+ let agent = expr_ident(lctx, e.span, place_ident, None);
+ let args = vec![expr_mut_addr_of(lctx, e.span, agent, None)];
let call = make_call(lctx, &place_pointer, args);
mk_stmt_let(lctx, p_ptr_ident, call)
};
vec![],
value_expr,
e.span,
- hir::PopUnstableBlock);
+ hir::PopUnstableBlock,
+ None);
signal_block_expr(lctx,
vec![],
value_expr,
e.span,
- hir::PopUnsafeBlock(hir::CompilerGenerated))
+ hir::PopUnsafeBlock(hir::CompilerGenerated), None)
};
// push_unsafe!({
// InPlace::finalize(place)
// })
let expr = {
- let ptr = expr_ident(lctx, e.span, p_ptr_ident);
+ let ptr = expr_ident(lctx, e.span, p_ptr_ident, None);
let call_move_val_init =
hir::StmtSemi(
make_call(lctx, &move_val_init, vec![ptr, pop_unsafe_expr]),
lctx.next_id());
let call_move_val_init = respan(e.span, call_move_val_init);
- let place = expr_ident(lctx, e.span, place_ident);
+ let place = expr_ident(lctx, e.span, place_ident, None);
let call = make_call(lctx, &inplace_finalize, vec![place]);
signal_block_expr(lctx,
vec![P(call_move_val_init)],
call,
e.span,
- hir::PushUnsafeBlock(hir::CompilerGenerated))
+ hir::PushUnsafeBlock(hir::CompilerGenerated), None)
};
signal_block_expr(lctx,
vec![s1, s2, s3],
expr,
e.span,
- hir::PushUnstableBlock)
+ hir::PushUnstableBlock,
+ e.attrs.clone())
});
}
rules: hir::DefaultBlock,
span: span,
});
- expr_block(lctx, blk)
+ expr_block(lctx, blk, None)
})
}
_ => lower_expr(lctx, els),
// `<pat> => <body>`
let pat_arm = {
let body = lower_block(lctx, body);
- let body_expr = expr_block(lctx, body);
+ let body_expr = expr_block(lctx, body, None);
arm(vec![lower_pat(lctx, pat)], body_expr)
};
attrs: vec![],
pats: vec![pat_under],
guard: Some(cond),
- body: expr_block(lctx, then),
+ body: expr_block(lctx, then, None),
});
else_opt.map(|else_opt| (else_opt, true))
}
let pat_under = pat_wild(lctx, e.span);
let else_expr =
else_opt.unwrap_or_else(
- || expr_tuple(lctx, e.span, vec![]));
+ || expr_tuple(lctx, e.span, vec![], None));
arm(vec![pat_under], else_expr)
};
arms.push(else_arm);
let sub_expr = lower_expr(lctx, sub_expr);
+ // add attributes to the outer returned expr node
expr(lctx,
e.span,
hir::ExprMatch(sub_expr,
arms,
hir::MatchSource::IfLetDesugar {
contains_else_clause: contains_else_clause,
- }))
+ }),
+ e.attrs.clone())
});
}
// `<pat> => <body>`
let pat_arm = {
let body = lower_block(lctx, body);
- let body_expr = expr_block(lctx, body);
+ let body_expr = expr_block(lctx, body, None);
arm(vec![lower_pat(lctx, pat)], body_expr)
};
// `_ => break`
let break_arm = {
let pat_under = pat_wild(lctx, e.span);
- let break_expr = expr_break(lctx, e.span);
+ let break_expr = expr_break(lctx, e.span, None);
arm(vec![pat_under], break_expr)
};
e.span,
hir::ExprMatch(sub_expr,
arms,
- hir::MatchSource::WhileLetDesugar));
+ hir::MatchSource::WhileLetDesugar),
+ None);
// `[opt_ident]: loop { ... }`
let loop_block = block_expr(lctx, match_expr);
- expr(lctx, e.span, hir::ExprLoop(loop_block, opt_ident))
+ // add attributes to the outer returned expr node
+ expr(lctx, e.span, hir::ExprLoop(loop_block, opt_ident), e.attrs.clone())
});
}
id: lctx.next_id(),
node: hir::ExprBlock(body_block),
span: body_span,
+ attrs: None,
});
let pat = lower_pat(lctx, pat);
let some_pat = pat_some(lctx, e.span, pat);
// `::std::option::Option::None => break`
let break_arm = {
- let break_expr = expr_break(lctx, e.span);
+ let break_expr = expr_break(lctx, e.span, None);
arm(vec![pat_none(lctx, e.span)], break_expr)
};
path_global(e.span, strs)
};
- let iter = expr_ident(lctx, e.span, iter);
- let ref_mut_iter = expr_mut_addr_of(lctx, e.span, iter);
- let next_path = expr_path(lctx, next_path);
- let next_expr = expr_call(lctx, e.span, next_path, vec![ref_mut_iter]);
+ let iter = expr_ident(lctx, e.span, iter, None);
+ let ref_mut_iter = expr_mut_addr_of(lctx, e.span, iter, None);
+ let next_path = expr_path(lctx, next_path, None);
+ let next_expr = expr_call(lctx,
+ e.span,
+ next_path,
+ vec![ref_mut_iter],
+ None);
let arms = vec![pat_arm, break_arm];
expr(lctx,
e.span,
- hir::ExprMatch(next_expr, arms, hir::MatchSource::ForLoopDesugar))
+ hir::ExprMatch(next_expr, arms, hir::MatchSource::ForLoopDesugar),
+ None)
};
// `[opt_ident]: loop { ... }`
let loop_block = block_expr(lctx, match_expr);
- let loop_expr = expr(lctx, e.span, hir::ExprLoop(loop_block, opt_ident));
+ let loop_expr = expr(lctx,
+ e.span,
+ hir::ExprLoop(loop_block, opt_ident),
+ None);
// `mut iter => { ... }`
let iter_arm = {
path_global(e.span, strs)
};
- let into_iter = expr_path(lctx, into_iter_path);
- expr_call(lctx, e.span, into_iter, vec![head])
+ let into_iter = expr_path(lctx, into_iter_path, None);
+ expr_call(lctx, e.span, into_iter, vec![head], None)
};
let match_expr = expr_match(lctx,
e.span,
into_iter_expr,
vec![iter_arm],
- hir::MatchSource::ForLoopDesugar);
+ hir::MatchSource::ForLoopDesugar,
+ None);
// `{ let result = ...; result }`
let result_ident = lctx.str_to_ident("result");
- let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr);
- let result = expr_ident(lctx, e.span, result_ident);
+ let let_stmt = stmt_let(lctx, e.span, false, result_ident, match_expr, None);
+ let result = expr_ident(lctx, e.span, result_ident, None);
let block = block_all(lctx, e.span, vec![let_stmt], Some(result));
- expr_block(lctx, block)
+ // add the attributes to the outer returned expr node
+ expr_block(lctx, block, e.attrs.clone())
});
}