Made ast::blk not use spanned<T> anymore.
This commit is contained in:
parent
4bd716ac8e
commit
0cc70743d2
@ -422,7 +422,7 @@ pub fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: &input,
|
||||
pprust::node_block(s, ref blk) => {
|
||||
pp::space(s.s);
|
||||
pprust::synth_comment(
|
||||
s, ~"block " + int::to_str(blk.node.id));
|
||||
s, ~"block " + int::to_str(blk.id));
|
||||
}
|
||||
pprust::node_expr(s, expr) => {
|
||||
pp::space(s.s);
|
||||
|
@ -33,7 +33,7 @@ pub fn strip_items(crate: &ast::crate, in_cfg: in_cfg_pred)
|
||||
|
||||
let precursor = @fold::AstFoldFns {
|
||||
fold_mod: |a,b| fold_mod(ctxt, a, b),
|
||||
fold_block: fold::wrap(|a,b| fold_block(ctxt, a, b) ),
|
||||
fold_block: |a,b| fold_block(ctxt, a, b),
|
||||
fold_foreign_mod: |a,b| fold_foreign_mod(ctxt, a, b),
|
||||
fold_item_underscore: |a,b| {
|
||||
// Bad copy.
|
||||
@ -133,21 +133,22 @@ fn filter_stmt(cx: @Context, stmt: @ast::stmt) ->
|
||||
|
||||
fn fold_block(
|
||||
cx: @Context,
|
||||
b: &ast::blk_,
|
||||
b: &ast::blk,
|
||||
fld: @fold::ast_fold
|
||||
) -> ast::blk_ {
|
||||
) -> ast::blk {
|
||||
let resulting_stmts = do b.stmts.iter().filter_map |a| {
|
||||
filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt))
|
||||
}.collect();
|
||||
let filtered_view_items = do b.view_items.iter().filter_map |a| {
|
||||
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
|
||||
}.collect();
|
||||
ast::blk_ {
|
||||
ast::blk {
|
||||
view_items: filtered_view_items,
|
||||
stmts: resulting_stmts,
|
||||
expr: b.expr.map(|x| fld.fold_expr(*x)),
|
||||
id: b.id,
|
||||
rules: b.rules,
|
||||
span: b.span,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) {
|
||||
// nested items, as otherwise it would get confused when translating
|
||||
// inlined items.
|
||||
fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
|
||||
fn drop_nested_items(blk: &ast::blk_, fld: @fold::ast_fold) -> ast::blk_ {
|
||||
fn drop_nested_items(blk: &ast::blk, fld: @fold::ast_fold) -> ast::blk {
|
||||
let stmts_sans_items = do blk.stmts.iter().filter_map |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
|
||||
@ -300,19 +300,20 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
|
||||
ast::stmt_mac(*) => fail!("unexpanded macro in astencode")
|
||||
}
|
||||
}.collect();
|
||||
let blk_sans_items = ast::blk_ {
|
||||
let blk_sans_items = ast::blk {
|
||||
view_items: ~[], // I don't know if we need the view_items here,
|
||||
// but it doesn't break tests!
|
||||
stmts: stmts_sans_items,
|
||||
expr: blk.expr,
|
||||
id: blk.id,
|
||||
rules: blk.rules
|
||||
rules: blk.rules,
|
||||
span: blk.span,
|
||||
};
|
||||
fold::noop_fold_block(&blk_sans_items, fld)
|
||||
}
|
||||
|
||||
let fld = fold::make_fold(@fold::AstFoldFns {
|
||||
fold_block: fold::wrap(drop_nested_items),
|
||||
fold_block: drop_nested_items,
|
||||
.. *fold::default_ast_fold()
|
||||
});
|
||||
|
||||
|
@ -44,7 +44,7 @@ pub fn check_loans(bccx: @BorrowckCtxt,
|
||||
move_data: move_data::FlowedMoveData,
|
||||
all_loans: &[Loan],
|
||||
body: &ast::blk) {
|
||||
debug!("check_loans(body id=%?)", body.node.id);
|
||||
debug!("check_loans(body id=%?)", body.id);
|
||||
|
||||
let clcx = @mut CheckLoanCtxt {
|
||||
bccx: bccx,
|
||||
@ -751,5 +751,5 @@ fn check_loans_in_block<'a>(blk: &ast::blk,
|
||||
visit::vt<@mut CheckLoanCtxt<'a>>))
|
||||
{
|
||||
visit::visit_block(blk, (this, vt));
|
||||
this.check_for_conflicting_loans(blk.node.id);
|
||||
this.check_for_conflicting_loans(blk.id);
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ pub fn gather_loans(bccx: @BorrowckCtxt,
|
||||
bccx: bccx,
|
||||
id_range: id_range::max(),
|
||||
all_loans: @mut ~[],
|
||||
item_ub: body.node.id,
|
||||
repeating_ids: ~[body.node.id],
|
||||
item_ub: body.id,
|
||||
repeating_ids: ~[body.id],
|
||||
move_data: @mut MoveData::new()
|
||||
};
|
||||
glcx.gather_fn_arg_patterns(decl, body);
|
||||
@ -123,9 +123,9 @@ fn gather_loans_in_fn(fk: &visit::fn_kind,
|
||||
|
||||
// Visit closures as part of the containing item.
|
||||
&visit::fk_anon(*) | &visit::fk_fn_block(*) => {
|
||||
this.push_repeating_id(body.node.id);
|
||||
this.push_repeating_id(body.id);
|
||||
visit::visit_fn(fk, decl, body, sp, id, (this, v));
|
||||
this.pop_repeating_id(body.node.id);
|
||||
this.pop_repeating_id(body.id);
|
||||
this.gather_fn_arg_patterns(decl, body);
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ fn gather_loans_in_fn(fk: &visit::fn_kind,
|
||||
fn gather_loans_in_block(blk: &ast::blk,
|
||||
(this, vt): (@mut GatherLoanCtxt,
|
||||
visit::vt<@mut GatherLoanCtxt>)) {
|
||||
this.id_range.add(blk.node.id);
|
||||
this.id_range.add(blk.id);
|
||||
visit::visit_block(blk, (this, vt));
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
||||
let cmt = this.bccx.cat_expr(ex_v);
|
||||
for arms.iter().advance |arm| {
|
||||
for arm.pats.iter().advance |pat| {
|
||||
this.gather_pat(cmt, *pat, Some((arm.body.node.id, ex.id)));
|
||||
this.gather_pat(cmt, *pat, Some((arm.body.id, ex.id)));
|
||||
}
|
||||
}
|
||||
visit::visit_expr(ex, (this, vt));
|
||||
@ -268,16 +268,16 @@ fn gather_loans_in_expr(ex: @ast::expr,
|
||||
this.pop_repeating_id(cond.id);
|
||||
|
||||
// during body, can only root for the body
|
||||
this.push_repeating_id(body.node.id);
|
||||
this.push_repeating_id(body.id);
|
||||
(vt.visit_block)(body, (this, vt));
|
||||
this.pop_repeating_id(body.node.id);
|
||||
this.pop_repeating_id(body.id);
|
||||
}
|
||||
|
||||
// see explanation attached to the `root_ub` field:
|
||||
ast::expr_loop(ref body, _) => {
|
||||
this.push_repeating_id(body.node.id);
|
||||
this.push_repeating_id(body.id);
|
||||
visit::visit_expr(ex, (this, vt));
|
||||
this.pop_repeating_id(body.node.id);
|
||||
this.pop_repeating_id(body.id);
|
||||
}
|
||||
|
||||
ast::expr_fn_block(*) => {
|
||||
@ -623,7 +623,7 @@ impl GatherLoanCtxt {
|
||||
let arg_cmt = mc_ctxt.cat_rvalue(
|
||||
arg.id,
|
||||
arg.pat.span,
|
||||
body.node.id, // Arguments live only as long as the fn body.
|
||||
body.id, // Arguments live only as long as the fn body.
|
||||
arg_ty);
|
||||
|
||||
self.gather_pat(arg_cmt, arg.pat, None);
|
||||
|
@ -53,13 +53,13 @@ pub fn construct(tcx: ty::ctxt,
|
||||
impl CFGBuilder {
|
||||
fn block(&mut self, blk: &ast::blk, pred: CFGIndex) -> CFGIndex {
|
||||
let mut stmts_exit = pred;
|
||||
for blk.node.stmts.iter().advance |&stmt| {
|
||||
for blk.stmts.iter().advance |&stmt| {
|
||||
stmts_exit = self.stmt(stmt, stmts_exit);
|
||||
}
|
||||
|
||||
let expr_exit = self.opt_expr(blk.node.expr, stmts_exit);
|
||||
let expr_exit = self.opt_expr(blk.expr, stmts_exit);
|
||||
|
||||
self.add_node(blk.node.id, [expr_exit])
|
||||
self.add_node(blk.id, [expr_exit])
|
||||
}
|
||||
|
||||
fn stmt(&mut self, stmt: @ast::stmt, pred: CFGIndex) -> CFGIndex {
|
||||
|
@ -330,7 +330,7 @@ impl<O:DataFlowOperator+Copy+'static> DataFlowContext<O> {
|
||||
let pre: @fn(pprust::ann_node) = |node| {
|
||||
let (ps, id) = match node {
|
||||
pprust::node_expr(ps, expr) => (ps, expr.id),
|
||||
pprust::node_block(ps, blk) => (ps, blk.node.id),
|
||||
pprust::node_block(ps, blk) => (ps, blk.id),
|
||||
pprust::node_item(ps, _) => (ps, 0),
|
||||
pprust::node_pat(ps, pat) => (ps, pat.id)
|
||||
};
|
||||
@ -383,18 +383,18 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
|
||||
blk: &ast::blk,
|
||||
in_out: &mut [uint],
|
||||
loop_scopes: &mut ~[LoopScope]) {
|
||||
debug!("DataFlowContext::walk_block(blk.node.id=%?, in_out=%s)",
|
||||
blk.node.id, bits_to_str(reslice(in_out)));
|
||||
debug!("DataFlowContext::walk_block(blk.id=%?, in_out=%s)",
|
||||
blk.id, bits_to_str(reslice(in_out)));
|
||||
|
||||
self.merge_with_entry_set(blk.node.id, in_out);
|
||||
self.merge_with_entry_set(blk.id, in_out);
|
||||
|
||||
for blk.node.stmts.iter().advance |&stmt| {
|
||||
for blk.stmts.iter().advance |&stmt| {
|
||||
self.walk_stmt(stmt, in_out, loop_scopes);
|
||||
}
|
||||
|
||||
self.walk_opt_expr(blk.node.expr, in_out, loop_scopes);
|
||||
self.walk_opt_expr(blk.expr, in_out, loop_scopes);
|
||||
|
||||
self.dfcx.apply_gen_kill(blk.node.id, in_out);
|
||||
self.dfcx.apply_gen_kill(blk.id, in_out);
|
||||
}
|
||||
|
||||
fn walk_stmt(&mut self,
|
||||
|
@ -99,9 +99,9 @@ pub fn check_crate(tcx: ty::ctxt,
|
||||
|
||||
visit_block: |block, (_, visitor)| {
|
||||
let old_unsafe_context = context.unsafe_context;
|
||||
if block.node.rules == unsafe_blk &&
|
||||
if block.rules == unsafe_blk &&
|
||||
context.unsafe_context == SafeContext {
|
||||
context.unsafe_context = UnsafeBlock(block.node.id)
|
||||
context.unsafe_context = UnsafeBlock(block.id)
|
||||
}
|
||||
|
||||
visit::visit_block(block, ((), visitor));
|
||||
|
@ -916,8 +916,8 @@ fn lint_unused_unsafe() -> visit::vt<@mut Context> {
|
||||
visit::mk_vt(@visit::Visitor {
|
||||
visit_expr: |e, (cx, vt): (@mut Context, visit::vt<@mut Context>)| {
|
||||
match e.node {
|
||||
ast::expr_block(ref blk) if blk.node.rules == ast::unsafe_blk => {
|
||||
if !cx.tcx.used_unsafe.contains(&blk.node.id) {
|
||||
ast::expr_block(ref blk) if blk.rules == ast::unsafe_blk => {
|
||||
if !cx.tcx.used_unsafe.contains(&blk.id) {
|
||||
cx.span_lint(unused_unsafe, blk.span,
|
||||
"unnecessary `unsafe` block");
|
||||
}
|
||||
|
@ -886,7 +886,7 @@ impl Liveness {
|
||||
self.tcx.sess.intr()));
|
||||
|
||||
let entry_ln: LiveNode =
|
||||
self.with_loop_nodes(body.node.id, self.s.exit_ln, self.s.exit_ln,
|
||||
self.with_loop_nodes(body.id, self.s.exit_ln, self.s.exit_ln,
|
||||
|| { self.propagate_through_fn_block(decl, body) });
|
||||
|
||||
// hack to skip the loop unless debug! is enabled:
|
||||
@ -895,7 +895,7 @@ impl Liveness {
|
||||
for uint::range(0u, self.ir.num_live_nodes) |ln_idx| {
|
||||
debug!("%s", self.ln_str(LiveNode(ln_idx)));
|
||||
}
|
||||
body.node.id
|
||||
body.id
|
||||
},
|
||||
entry_ln.to_str());
|
||||
|
||||
@ -907,7 +907,7 @@ impl Liveness {
|
||||
// the fallthrough exit is only for those cases where we do not
|
||||
// explicitly return:
|
||||
self.init_from_succ(self.s.fallthrough_ln, self.s.exit_ln);
|
||||
if blk.node.expr.is_none() {
|
||||
if blk.expr.is_none() {
|
||||
self.acc(self.s.fallthrough_ln, self.s.no_ret_var, ACC_READ)
|
||||
}
|
||||
|
||||
@ -916,8 +916,8 @@ impl Liveness {
|
||||
|
||||
pub fn propagate_through_block(&self, blk: &blk, succ: LiveNode)
|
||||
-> LiveNode {
|
||||
let succ = self.propagate_through_opt_expr(blk.node.expr, succ);
|
||||
do blk.node.stmts.rev_iter().fold(succ) |succ, stmt| {
|
||||
let succ = self.propagate_through_opt_expr(blk.expr, succ);
|
||||
do blk.stmts.rev_iter().fold(succ) |succ, stmt| {
|
||||
self.propagate_through_stmt(*stmt, succ)
|
||||
}
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ impl Liveness {
|
||||
The next-node for a break is the successor of the entire
|
||||
loop. The next-node for a continue is the top of this loop.
|
||||
*/
|
||||
self.with_loop_nodes(blk.node.id, succ,
|
||||
self.with_loop_nodes(blk.id, succ,
|
||||
self.live_node(expr.id, expr.span), || {
|
||||
|
||||
// the construction of a closure itself is not important,
|
||||
|
@ -285,13 +285,13 @@ impl VisitContext {
|
||||
* meaning either copied or moved depending on its type.
|
||||
*/
|
||||
|
||||
debug!("consume_block(blk.id=%?)", blk.node.id);
|
||||
debug!("consume_block(blk.id=%?)", blk.id);
|
||||
|
||||
for blk.node.stmts.iter().advance |stmt| {
|
||||
for blk.stmts.iter().advance |stmt| {
|
||||
(visitor.visit_stmt)(*stmt, (*self, visitor));
|
||||
}
|
||||
|
||||
for blk.node.expr.iter().advance |tail_expr| {
|
||||
for blk.expr.iter().advance |tail_expr| {
|
||||
self.consume_expr(*tail_expr, visitor);
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
|
||||
visit_block: |block, (method_map, visitor)| {
|
||||
// Gather up all the privileged items.
|
||||
let mut n_added = 0;
|
||||
for block.node.stmts.iter().advance |stmt| {
|
||||
for block.stmts.iter().advance |stmt| {
|
||||
match stmt.node {
|
||||
stmt_decl(decl, _) => {
|
||||
match decl.node {
|
||||
|
@ -324,11 +324,11 @@ fn parent_to_expr(cx: Context, child_id: ast::node_id, sp: span) {
|
||||
|
||||
fn resolve_block(blk: &ast::blk, (cx, visitor): (Context, visit::vt<Context>)) {
|
||||
// Record the parent of this block.
|
||||
parent_to_expr(cx, blk.node.id, blk.span);
|
||||
parent_to_expr(cx, blk.id, blk.span);
|
||||
|
||||
// Descend.
|
||||
let new_cx = Context {var_parent: Some(blk.node.id),
|
||||
parent: Some(blk.node.id),
|
||||
let new_cx = Context {var_parent: Some(blk.id),
|
||||
parent: Some(blk.id),
|
||||
..cx};
|
||||
visit::visit_block(blk, (new_cx, visitor));
|
||||
}
|
||||
@ -420,20 +420,20 @@ fn resolve_fn(fk: &visit::fn_kind,
|
||||
visit::vt<Context>)) {
|
||||
debug!("region::resolve_fn(id=%?, \
|
||||
span=%?, \
|
||||
body.node.id=%?, \
|
||||
body.id=%?, \
|
||||
cx.parent=%?)",
|
||||
id,
|
||||
cx.sess.codemap.span_to_str(sp),
|
||||
body.node.id,
|
||||
body.id,
|
||||
cx.parent);
|
||||
|
||||
// The arguments and `self` are parented to the body of the fn.
|
||||
let decl_cx = Context {parent: Some(body.node.id),
|
||||
var_parent: Some(body.node.id),
|
||||
let decl_cx = Context {parent: Some(body.id),
|
||||
var_parent: Some(body.id),
|
||||
..cx};
|
||||
match *fk {
|
||||
visit::fk_method(_, _, method) => {
|
||||
cx.region_maps.record_parent(method.self_id, body.node.id);
|
||||
cx.region_maps.record_parent(method.self_id, body.id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1069,12 +1069,12 @@ impl Resolver {
|
||||
|
||||
pub fn block_needs_anonymous_module(@mut self, block: &blk) -> bool {
|
||||
// If the block has view items, we need an anonymous module.
|
||||
if block.node.view_items.len() > 0 {
|
||||
if block.view_items.len() > 0 {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check each statement.
|
||||
for block.node.stmts.iter().advance |statement| {
|
||||
for block.stmts.iter().advance |statement| {
|
||||
match statement.node {
|
||||
stmt_decl(declaration, _) => {
|
||||
match declaration.node {
|
||||
@ -1566,7 +1566,7 @@ impl Resolver {
|
||||
vt<ReducedGraphParent>)) {
|
||||
let new_parent;
|
||||
if self.block_needs_anonymous_module(block) {
|
||||
let block_id = block.node.id;
|
||||
let block_id = block.id;
|
||||
|
||||
debug!("(building reduced graph for block) creating a new \
|
||||
anonymous module for block %d",
|
||||
@ -4096,7 +4096,7 @@ impl Resolver {
|
||||
|
||||
// Move down in the graph, if there's an anonymous module rooted here.
|
||||
let orig_module = self.current_module;
|
||||
match self.current_module.anonymous_children.find(&block.node.id) {
|
||||
match self.current_module.anonymous_children.find(&block.id) {
|
||||
None => { /* Nothing to do. */ }
|
||||
Some(&anonymous_module) => {
|
||||
debug!("(resolving block) found anonymous module, moving \
|
||||
@ -4989,7 +4989,7 @@ impl Resolver {
|
||||
}
|
||||
|
||||
expr_fn_block(ref fn_decl, ref block) => {
|
||||
self.resolve_function(FunctionRibKind(expr.id, block.node.id),
|
||||
self.resolve_function(FunctionRibKind(expr.id, block.id),
|
||||
Some(fn_decl),
|
||||
NoTypeParameters,
|
||||
block,
|
||||
|
@ -1430,7 +1430,7 @@ pub fn with_scope_datumblock(bcx: block, opt_node_info: Option<NodeInfo>,
|
||||
}
|
||||
|
||||
pub fn block_locals(b: &ast::blk, it: &fn(@ast::local)) {
|
||||
for b.node.stmts.iter().advance |s| {
|
||||
for b.stmts.iter().advance |s| {
|
||||
match s.node {
|
||||
ast::stmt_decl(d, _) => {
|
||||
match d.node {
|
||||
@ -1858,7 +1858,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
|
||||
let bcx_top = top_scope_block(fcx, body.info());
|
||||
let mut bcx = bcx_top;
|
||||
let lltop = bcx.llbb;
|
||||
let block_ty = node_id_type(bcx, body.node.id);
|
||||
let block_ty = node_id_type(bcx, body.id);
|
||||
|
||||
let arg_tys = ty::ty_fn_args(node_id_type(bcx, id));
|
||||
bcx = copy_args_to_allocas(fcx, bcx, decl.inputs, raw_llargs, arg_tys);
|
||||
@ -1869,7 +1869,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
|
||||
// translation calls that don't have a return value (trans_crate,
|
||||
// trans_mod, trans_item, et cetera) and those that do
|
||||
// (trans_block, trans_expr, et cetera).
|
||||
if body.node.expr.is_none() || ty::type_is_bot(block_ty) ||
|
||||
if body.expr.is_none() || ty::type_is_bot(block_ty) ||
|
||||
ty::type_is_nil(block_ty)
|
||||
{
|
||||
bcx = controlflow::trans_block(bcx, body, expr::Ignore);
|
||||
@ -2132,7 +2132,7 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
|
||||
item.id,
|
||||
item.attrs);
|
||||
} else {
|
||||
for body.node.stmts.iter().advance |stmt| {
|
||||
for body.stmts.iter().advance |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(i),
|
||||
_ }, _) => {
|
||||
|
@ -481,7 +481,7 @@ impl get_node_info for ast::expr {
|
||||
|
||||
impl get_node_info for ast::blk {
|
||||
fn info(&self) -> Option<NodeInfo> {
|
||||
Some(NodeInfo {id: self.node.id,
|
||||
Some(NodeInfo {id: self.id,
|
||||
callee_id: None,
|
||||
span: self.span})
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ use syntax::codemap::span;
|
||||
pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
|
||||
let _icx = push_ctxt("trans_block");
|
||||
let mut bcx = bcx;
|
||||
for b.node.stmts.iter().advance |s| {
|
||||
for b.stmts.iter().advance |s| {
|
||||
debuginfo::update_source_pos(bcx, b.span);
|
||||
bcx = trans_stmt(bcx, *s);
|
||||
}
|
||||
match b.node.expr {
|
||||
match b.expr {
|
||||
Some(e) => {
|
||||
debuginfo::update_source_pos(bcx, e.span);
|
||||
bcx = expr::trans_into(bcx, e, dest);
|
||||
@ -58,7 +58,7 @@ pub fn trans_if(bcx: block,
|
||||
dest: expr::Dest)
|
||||
-> block {
|
||||
debug!("trans_if(bcx=%s, cond=%s, thn=%?, dest=%s)",
|
||||
bcx.to_str(), bcx.expr_to_str(cond), thn.node.id,
|
||||
bcx.to_str(), bcx.expr_to_str(cond), thn.id,
|
||||
dest.to_str(bcx.ccx()));
|
||||
let _indenter = indenter();
|
||||
|
||||
|
@ -414,7 +414,7 @@ pub fn handle_body(cx: &Context, body: &blk) {
|
||||
},
|
||||
visit_block: |b, (cx, v)| {
|
||||
visit::visit_block(b, (cx, v));
|
||||
for b.node.expr.iter().advance |e| {
|
||||
for b.expr.iter().advance |e| {
|
||||
node_type_needs(cx, use_repr, e.id);
|
||||
}
|
||||
},
|
||||
|
@ -2840,7 +2840,7 @@ pub fn tys_in_fn_sig(sig: &FnSig) -> ~[t] {
|
||||
|
||||
// Type accessors for AST nodes
|
||||
pub fn block_ty(cx: ctxt, b: &ast::blk) -> t {
|
||||
return node_id_to_type(cx, b.node.id);
|
||||
return node_id_to_type(cx, b.id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,14 +72,14 @@ pub fn check_match(fcx: @mut FnCtxt,
|
||||
None => ()
|
||||
}
|
||||
check_block(fcx, &arm.body);
|
||||
let bty = fcx.node_ty(arm.body.node.id);
|
||||
let bty = fcx.node_ty(arm.body.id);
|
||||
saw_err = saw_err || ty::type_is_error(bty);
|
||||
if guard_err {
|
||||
fcx.write_error(arm.body.node.id);
|
||||
fcx.write_error(arm.body.id);
|
||||
saw_err = true;
|
||||
}
|
||||
else if guard_bot {
|
||||
fcx.write_bot(arm.body.node.id);
|
||||
fcx.write_bot(arm.body.id);
|
||||
}
|
||||
|
||||
result_ty =
|
||||
|
@ -200,8 +200,8 @@ impl PurityState {
|
||||
ast::unsafe_fn if self.from_fn => *self,
|
||||
|
||||
purity => {
|
||||
let (purity, def) = match blk.node.rules {
|
||||
ast::unsafe_blk => (ast::unsafe_fn, blk.node.id),
|
||||
let (purity, def) = match blk.rules {
|
||||
ast::unsafe_blk => (ast::unsafe_fn, blk.id),
|
||||
ast::default_blk => (purity, self.def),
|
||||
};
|
||||
PurityState{ def: def,
|
||||
@ -365,7 +365,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
let (isr, opt_self_ty, fn_sig) =
|
||||
replace_bound_regions_in_fn_sig(
|
||||
tcx, inherited_isr, opt_self_ty, fn_sig,
|
||||
|br| ty::re_free(ty::FreeRegion {scope_id: body.node.id,
|
||||
|br| ty::re_free(ty::FreeRegion {scope_id: body.id,
|
||||
bound_region: br}));
|
||||
let opt_self_info =
|
||||
opt_self_info.map(
|
||||
@ -399,7 +399,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
ret_ty: ret_ty,
|
||||
indirect_ret_ty: indirect_ret_ty,
|
||||
ps: PurityState::function(purity, id),
|
||||
region_lb: body.node.id,
|
||||
region_lb: body.id,
|
||||
in_scope_regions: isr,
|
||||
fn_kind: fn_kind,
|
||||
inh: inherited,
|
||||
@ -412,7 +412,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
|
||||
// We unify the tail expr's type with the
|
||||
// function result type, if there is a tail expr.
|
||||
match body.node.expr {
|
||||
match body.expr {
|
||||
Some(tail_expr) => {
|
||||
let tail_expr_ty = fcx.expr_ty(tail_expr);
|
||||
// Special case: we print a special error if there appears
|
||||
@ -515,7 +515,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
|
||||
// non-obvious: the `blk` variable maps to region lb, so
|
||||
// we have to keep this up-to-date. This
|
||||
// is... unfortunate. It'd be nice to not need this.
|
||||
do fcx.with_region_lb(b.node.id) {
|
||||
do fcx.with_region_lb(b.id) {
|
||||
visit::visit_block(b, (e, v));
|
||||
}
|
||||
};
|
||||
@ -1456,7 +1456,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||
let branches_ty = match opt_else_expr {
|
||||
Some(else_expr) => {
|
||||
check_block_with_expected(fcx, then_blk, expected);
|
||||
let then_ty = fcx.node_ty(then_blk.node.id);
|
||||
let then_ty = fcx.node_ty(then_blk.id);
|
||||
check_expr_with_opt_hint(fcx, else_expr, expected);
|
||||
let else_ty = fcx.expr_ty(else_expr);
|
||||
infer::common_supertype(fcx.infcx(),
|
||||
@ -2533,7 +2533,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||
check_expr_has_type(fcx, cond, ty::mk_bool());
|
||||
check_block_no_value(fcx, body);
|
||||
let cond_ty = fcx.expr_ty(cond);
|
||||
let body_ty = fcx.node_ty(body.node.id);
|
||||
let body_ty = fcx.node_ty(body.id);
|
||||
if ty::type_is_error(cond_ty) || ty::type_is_error(body_ty) {
|
||||
fcx.write_error(id);
|
||||
}
|
||||
@ -2598,7 +2598,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||
}
|
||||
ast::expr_block(ref b) => {
|
||||
check_block_with_expected(fcx, b, expected);
|
||||
fcx.write_ty(id, fcx.node_ty(b.node.id));
|
||||
fcx.write_ty(id, fcx.node_ty(b.id));
|
||||
}
|
||||
ast::expr_call(f, ref args, sugar) => {
|
||||
check_call(fcx, expr.id, expr, f, *args, sugar);
|
||||
@ -2959,12 +2959,12 @@ pub fn check_stmt(fcx: @mut FnCtxt, stmt: @ast::stmt) {
|
||||
|
||||
pub fn check_block_no_value(fcx: @mut FnCtxt, blk: &ast::blk) {
|
||||
check_block_with_expected(fcx, blk, Some(ty::mk_nil()));
|
||||
let blkty = fcx.node_ty(blk.node.id);
|
||||
let blkty = fcx.node_ty(blk.id);
|
||||
if ty::type_is_error(blkty) {
|
||||
fcx.write_error(blk.node.id);
|
||||
fcx.write_error(blk.id);
|
||||
}
|
||||
else if ty::type_is_bot(blkty) {
|
||||
fcx.write_bot(blk.node.id);
|
||||
fcx.write_bot(blk.id);
|
||||
}
|
||||
else {
|
||||
let nilty = ty::mk_nil();
|
||||
@ -2982,12 +2982,12 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
|
||||
let purity_state = fcx.ps.recurse(blk);
|
||||
let prev = replace(&mut fcx.ps, purity_state);
|
||||
|
||||
do fcx.with_region_lb(blk.node.id) {
|
||||
do fcx.with_region_lb(blk.id) {
|
||||
let mut warned = false;
|
||||
let mut last_was_bot = false;
|
||||
let mut any_bot = false;
|
||||
let mut any_err = false;
|
||||
for blk.node.stmts.iter().advance |s| {
|
||||
for blk.stmts.iter().advance |s| {
|
||||
check_stmt(fcx, *s);
|
||||
let s_id = ast_util::stmt_id(*s);
|
||||
let s_ty = fcx.node_ty(s_id);
|
||||
@ -3009,15 +3009,15 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
|
||||
any_bot = any_bot || ty::type_is_bot(s_ty);
|
||||
any_err = any_err || ty::type_is_error(s_ty);
|
||||
}
|
||||
match blk.node.expr {
|
||||
match blk.expr {
|
||||
None => if any_err {
|
||||
fcx.write_error(blk.node.id);
|
||||
fcx.write_error(blk.id);
|
||||
}
|
||||
else if any_bot {
|
||||
fcx.write_bot(blk.node.id);
|
||||
fcx.write_bot(blk.id);
|
||||
}
|
||||
else {
|
||||
fcx.write_nil(blk.node.id);
|
||||
fcx.write_nil(blk.id);
|
||||
},
|
||||
Some(e) => {
|
||||
if any_bot && !warned {
|
||||
@ -3025,12 +3025,12 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
|
||||
}
|
||||
check_expr_with_opt_hint(fcx, e, expected);
|
||||
let ety = fcx.expr_ty(e);
|
||||
fcx.write_ty(blk.node.id, ety);
|
||||
fcx.write_ty(blk.id, ety);
|
||||
if any_err {
|
||||
fcx.write_error(blk.node.id);
|
||||
fcx.write_error(blk.id);
|
||||
}
|
||||
else if any_bot {
|
||||
fcx.write_bot(blk.node.id);
|
||||
fcx.write_bot(blk.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -155,7 +155,7 @@ pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::expr) {
|
||||
|
||||
pub fn regionck_fn(fcx: @mut FnCtxt, blk: &ast::blk) {
|
||||
let rcx = @mut Rcx { fcx: fcx, errors_reported: 0,
|
||||
repeating_scope: blk.node.id };
|
||||
repeating_scope: blk.id };
|
||||
if fcx.err_count_since_creation() == 0 {
|
||||
// regionck assumes typeck succeeded
|
||||
let v = regionck_visitor();
|
||||
@ -188,7 +188,7 @@ fn visit_item(_item: @ast::item, (_rcx, _v): (@mut Rcx, rvt)) {
|
||||
}
|
||||
|
||||
fn visit_block(b: &ast::blk, (rcx, v): (@mut Rcx, rvt)) {
|
||||
rcx.fcx.tcx().region_maps.record_cleanup_scope(b.node.id);
|
||||
rcx.fcx.tcx().region_maps.record_cleanup_scope(b.id);
|
||||
visit::visit_block(b, (rcx, v));
|
||||
}
|
||||
|
||||
@ -287,11 +287,11 @@ fn visit_expr(expr: @ast::expr, (rcx, v): (@mut Rcx, rvt)) {
|
||||
}
|
||||
}
|
||||
ast::expr_loop(ref body, _) => {
|
||||
tcx.region_maps.record_cleanup_scope(body.node.id);
|
||||
tcx.region_maps.record_cleanup_scope(body.id);
|
||||
}
|
||||
ast::expr_while(cond, ref body) => {
|
||||
tcx.region_maps.record_cleanup_scope(cond.id);
|
||||
tcx.region_maps.record_cleanup_scope(body.node.id);
|
||||
tcx.region_maps.record_cleanup_scope(body.id);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@ -434,7 +434,7 @@ fn visit_expr(expr: @ast::expr, (rcx, v): (@mut Rcx, rvt)) {
|
||||
}
|
||||
|
||||
ast::expr_loop(ref body, _) => {
|
||||
let repeating_scope = rcx.set_repeating_scope(body.node.id);
|
||||
let repeating_scope = rcx.set_repeating_scope(body.id);
|
||||
visit::visit_expr(expr, (rcx, v));
|
||||
rcx.set_repeating_scope(repeating_scope);
|
||||
}
|
||||
@ -443,7 +443,7 @@ fn visit_expr(expr: @ast::expr, (rcx, v): (@mut Rcx, rvt)) {
|
||||
let repeating_scope = rcx.set_repeating_scope(cond.id);
|
||||
(v.visit_expr)(cond, (rcx, v));
|
||||
|
||||
rcx.set_repeating_scope(body.node.id);
|
||||
rcx.set_repeating_scope(body.id);
|
||||
(v.visit_block)(body, (rcx, v));
|
||||
|
||||
rcx.set_repeating_scope(repeating_scope);
|
||||
@ -486,7 +486,7 @@ fn check_expr_fn_block(rcx: @mut Rcx,
|
||||
_ => ()
|
||||
}
|
||||
|
||||
let repeating_scope = rcx.set_repeating_scope(body.node.id);
|
||||
let repeating_scope = rcx.set_repeating_scope(body.id);
|
||||
visit::visit_expr(expr, (rcx, v));
|
||||
rcx.set_repeating_scope(repeating_scope);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ fn visit_block(b: &ast::blk, (wbcx, v): (@mut WbCtxt, wb_vt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
resolve_type_vars_for_node(wbcx, b.span, b.node.id);
|
||||
resolve_type_vars_for_node(wbcx, b.span, b.id);
|
||||
visit::visit_block(b, (wbcx, v));
|
||||
}
|
||||
|
||||
|
@ -745,7 +745,7 @@ pub fn convert_methods(ccx: &CrateCtxt,
|
||||
write_ty_to_tcx(tcx, m.id, fty);
|
||||
tcx.methods.insert(mty.def_id, mty);
|
||||
ConvertedMethod {mty: mty, id: m.id,
|
||||
span: m.span, body_id: m.body.node.id}
|
||||
span: m.span, body_id: m.body.id}
|
||||
}).collect();
|
||||
|
||||
fn ty_of_method(ccx: &CrateCtxt,
|
||||
|
@ -346,7 +346,7 @@ impl Program {
|
||||
// helper functions to perform ast iteration
|
||||
fn each_user_local(blk: &ast::blk, f: &fn(@ast::local)) {
|
||||
do find_user_block(blk) |blk| {
|
||||
for blk.node.stmts.iter().advance |stmt| {
|
||||
for blk.stmts.iter().advance |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_decl(d, _) => {
|
||||
match d.node {
|
||||
@ -361,7 +361,7 @@ impl Program {
|
||||
}
|
||||
|
||||
fn find_user_block(blk: &ast::blk, f: &fn(&ast::blk)) {
|
||||
for blk.node.stmts.iter().advance |stmt| {
|
||||
for blk.stmts.iter().advance |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_semi(e, _) => {
|
||||
match e.node {
|
||||
|
@ -149,7 +149,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
do find_main(crate, sess) |blk| {
|
||||
// Fish out all the view items, be sure to record 'extern mod' items
|
||||
// differently beause they must appear before all 'use' statements
|
||||
for blk.node.view_items.iter().advance |vi| {
|
||||
for blk.view_items.iter().advance |vi| {
|
||||
let s = do with_pp(intr) |pp, _| {
|
||||
pprust::print_view_item(pp, vi);
|
||||
};
|
||||
@ -163,7 +163,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
|
||||
// Iterate through all of the block's statements, inserting them into
|
||||
// the correct portions of the program
|
||||
for blk.node.stmts.iter().advance |stmt| {
|
||||
for blk.stmts.iter().advance |stmt| {
|
||||
let s = do with_pp(intr) |pp, _| { pprust::print_stmt(pp, *stmt); };
|
||||
match stmt.node {
|
||||
ast::stmt_decl(d, _) => {
|
||||
@ -203,7 +203,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
|
||||
}
|
||||
}
|
||||
}
|
||||
result = do blk.node.expr.map_consume |e| {
|
||||
result = do blk.expr.map_consume |e| {
|
||||
do with_pp(intr) |pp, _| { pprust::print_expr(pp, e); }
|
||||
};
|
||||
}
|
||||
|
@ -215,15 +215,16 @@ pub enum meta_item_ {
|
||||
meta_name_value(@str, lit),
|
||||
}
|
||||
|
||||
pub type blk = spanned<blk_>;
|
||||
//pub type blk = spanned<blk_>;
|
||||
|
||||
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||
pub struct blk_ {
|
||||
pub struct blk {
|
||||
view_items: ~[view_item],
|
||||
stmts: ~[@stmt],
|
||||
expr: Option<@expr>,
|
||||
id: node_id,
|
||||
rules: blk_check_mode,
|
||||
span: span,
|
||||
}
|
||||
|
||||
#[deriving(Eq, Encodable, Decodable,IterBytes)]
|
||||
|
@ -190,7 +190,7 @@ pub fn map_fn(
|
||||
}
|
||||
|
||||
pub fn map_block(b: &blk, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
|
||||
cx.map.insert(b.node.id, node_block(/* FIXME (#2543) */ copy *b));
|
||||
cx.map.insert(b.id, node_block(/* FIXME (#2543) */ copy *b));
|
||||
visit::visit_block(b, (cx, v));
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
use ast::*;
|
||||
use ast;
|
||||
use ast_util;
|
||||
use codemap::{span, spanned};
|
||||
use codemap::{span, dummy_sp};
|
||||
use opt_vec;
|
||||
use parse::token;
|
||||
use visit;
|
||||
@ -194,21 +194,23 @@ pub fn is_call_expr(e: @expr) -> bool {
|
||||
}
|
||||
|
||||
pub fn block_from_expr(e: @expr) -> blk {
|
||||
let blk_ = default_block(~[], option::Some::<@expr>(e), e.id);
|
||||
return spanned {node: blk_, span: e.span};
|
||||
let mut blk = default_block(~[], option::Some::<@expr>(e), e.id);
|
||||
blk.span = e.span;
|
||||
return blk;
|
||||
}
|
||||
|
||||
pub fn default_block(
|
||||
stmts1: ~[@stmt],
|
||||
expr1: Option<@expr>,
|
||||
id1: node_id
|
||||
) -> blk_ {
|
||||
ast::blk_ {
|
||||
) -> blk {
|
||||
ast::blk {
|
||||
view_items: ~[],
|
||||
stmts: stmts1,
|
||||
expr: expr1,
|
||||
id: id1,
|
||||
rules: default_blk,
|
||||
span: dummy_sp(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,7 +439,7 @@ pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
|
||||
visit::visit_local(l, (t, vt));
|
||||
},
|
||||
visit_block: |b, (t, vt)| {
|
||||
vfn(b.node.id, copy t);
|
||||
vfn(b.id, copy t);
|
||||
visit::visit_block(b, (t, vt));
|
||||
},
|
||||
visit_stmt: |s, (t, vt)| {
|
||||
|
@ -400,14 +400,14 @@ impl AstBuilder for @ExtCtxt {
|
||||
view_items: ~[ast::view_item],
|
||||
stmts: ~[@ast::stmt],
|
||||
expr: Option<@ast::expr>) -> ast::blk {
|
||||
respan(span,
|
||||
ast::blk_ {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk,
|
||||
})
|
||||
ast::blk {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: self.next_id(),
|
||||
rules: ast::default_blk,
|
||||
span: span,
|
||||
}
|
||||
}
|
||||
|
||||
fn expr(&self, span: span, node: ast::expr_) -> @ast::expr {
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast::{blk_, crate, expr_, expr_mac, mac_invoc_tt};
|
||||
use ast::{blk, crate, expr_, expr_mac, mac_invoc_tt};
|
||||
use ast::{item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
|
||||
use ast::{illegal_ctxt};
|
||||
use ast;
|
||||
@ -394,13 +394,12 @@ pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> {
|
||||
|
||||
pub fn expand_block(extsbox: @mut SyntaxEnv,
|
||||
_cx: @ExtCtxt,
|
||||
blk: &blk_,
|
||||
sp: span,
|
||||
blk: &blk,
|
||||
fld: @ast_fold,
|
||||
orig: @fn(&blk_, span, @ast_fold) -> (blk_, span))
|
||||
-> (blk_, span) {
|
||||
orig: @fn(&blk, @ast_fold) -> blk)
|
||||
-> blk {
|
||||
// see note below about treatment of exts table
|
||||
with_exts_frame!(extsbox,false,orig(blk,sp,fld))
|
||||
with_exts_frame!(extsbox,false,orig(blk,fld))
|
||||
}
|
||||
|
||||
|
||||
@ -736,8 +735,8 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
|
||||
expand_item(extsbox, cx, item, recur, afp.fold_item),
|
||||
fold_stmt: |stmt,span,recur|
|
||||
expand_stmt(extsbox, cx, stmt, span, recur, afp.fold_stmt),
|
||||
fold_block: |blk,span,recur|
|
||||
expand_block(extsbox, cx, blk, span, recur, afp.fold_block),
|
||||
fold_block: |blk,recur|
|
||||
expand_block(extsbox, cx, blk, recur, afp.fold_block),
|
||||
new_span: |a| new_span(cx, a),
|
||||
.. *afp};
|
||||
let f = make_fold(f_pre);
|
||||
|
@ -51,7 +51,7 @@ pub struct AstFoldFns {
|
||||
fold_struct_field: @fn(@struct_field, @ast_fold) -> @struct_field,
|
||||
fold_item_underscore: @fn(&item_, @ast_fold) -> item_,
|
||||
fold_method: @fn(@method, @ast_fold) -> @method,
|
||||
fold_block: @fn(&blk_, span, @ast_fold) -> (blk_, span),
|
||||
fold_block: @fn(&blk, @ast_fold) -> blk,
|
||||
fold_stmt: @fn(&stmt_, span, @ast_fold) -> (Option<stmt_>, span),
|
||||
fold_arm: @fn(&arm, @ast_fold) -> arm,
|
||||
fold_pat: @fn(&pat_, span, @ast_fold) -> (pat_, span),
|
||||
@ -372,7 +372,7 @@ fn noop_fold_method(m: @method, fld: @ast_fold) -> @method {
|
||||
}
|
||||
|
||||
|
||||
pub fn noop_fold_block(b: &blk_, fld: @ast_fold) -> blk_ {
|
||||
pub fn noop_fold_block(b: &blk, fld: @ast_fold) -> blk {
|
||||
let view_items = b.view_items.map(|x| fld.fold_view_item(x));
|
||||
let mut stmts = ~[];
|
||||
for b.stmts.iter().advance |stmt| {
|
||||
@ -381,12 +381,13 @@ pub fn noop_fold_block(b: &blk_, fld: @ast_fold) -> blk_ {
|
||||
Some(stmt) => stmts.push(stmt)
|
||||
}
|
||||
}
|
||||
ast::blk_ {
|
||||
ast::blk {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: b.expr.map(|x| fld.fold_expr(*x)),
|
||||
id: fld.new_id(b.id),
|
||||
rules: b.rules,
|
||||
span: b.span,
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,7 +795,7 @@ pub fn default_ast_fold() -> ast_fold_fns {
|
||||
fold_struct_field: noop_fold_struct_field,
|
||||
fold_item_underscore: noop_fold_item_underscore,
|
||||
fold_method: noop_fold_method,
|
||||
fold_block: wrap(noop_fold_block),
|
||||
fold_block: noop_fold_block,
|
||||
fold_stmt: |x, s, fld| (noop_fold_stmt(x, fld), s),
|
||||
fold_arm: noop_fold_arm,
|
||||
fold_pat: wrap(noop_fold_pat),
|
||||
@ -851,8 +852,7 @@ impl ast_fold for AstFoldFns {
|
||||
(self.fold_method)(x, self as @ast_fold)
|
||||
}
|
||||
fn fold_block(@self, x: &blk) -> blk {
|
||||
let (n, s) = (self.fold_block)(&x.node, x.span, self as @ast_fold);
|
||||
spanned { node: n, span: (self.new_span)(s) }
|
||||
(self.fold_block)(x, self as @ast_fold)
|
||||
}
|
||||
fn fold_stmt(@self, x: &stmt) -> Option<@stmt> {
|
||||
let (n_opt, s) = (self.fold_stmt)(&x.node, x.span, self as @ast_fold);
|
||||
|
@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
use ast;
|
||||
use codemap;
|
||||
|
||||
// does this expression require a semicolon to be treated
|
||||
// as a statement? The negation of this: 'can this expression
|
||||
@ -40,8 +39,7 @@ pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool {
|
||||
pub fn expr_is_simple_block(e: @ast::expr) -> bool {
|
||||
match e.node {
|
||||
ast::expr_block(
|
||||
codemap::spanned {
|
||||
node: ast::blk_ { rules: ast::default_blk, _ }, _ }
|
||||
ast::blk { rules: ast::default_blk, _ }
|
||||
) => true,
|
||||
_ => false
|
||||
}
|
||||
|
@ -557,27 +557,26 @@ mod test {
|
||||
lifetimes: opt_vec::Empty,
|
||||
ty_params: opt_vec::Empty,
|
||||
},
|
||||
spanned{
|
||||
ast::blk {
|
||||
view_items: ~[],
|
||||
stmts: ~[@spanned{
|
||||
node: ast::stmt_semi(@ast::expr{
|
||||
id: 6,
|
||||
node: ast::expr_path(
|
||||
ast::Path{
|
||||
span:sp(17,18),
|
||||
global:false,
|
||||
idents:~[str_to_ident("b")],
|
||||
rp:None,
|
||||
types: ~[]}),
|
||||
span: sp(17,18)},
|
||||
7), // fixme
|
||||
span: sp(17,18)}],
|
||||
expr: None,
|
||||
id: 8, // fixme
|
||||
rules: ast::default_blk, // no idea
|
||||
span: sp(15,21),
|
||||
node: ast::blk_{
|
||||
view_items: ~[],
|
||||
stmts: ~[@spanned{
|
||||
node: ast::stmt_semi(@ast::expr{
|
||||
id: 6,
|
||||
node: ast::expr_path(
|
||||
ast::Path{
|
||||
span:sp(17,18),
|
||||
global:false,
|
||||
idents:~[str_to_ident("b")],
|
||||
rp:None,
|
||||
types: ~[]}),
|
||||
span: sp(17,18)},
|
||||
7), // fixme
|
||||
span: sp(17,18)}],
|
||||
expr: None,
|
||||
id: 8, // fixme
|
||||
rules: ast::default_blk // no idea
|
||||
}}),
|
||||
}),
|
||||
vis: ast::inherited,
|
||||
span: sp(0,21)}));
|
||||
}
|
||||
|
@ -2245,15 +2245,15 @@ impl Parser {
|
||||
let lo = self.last_span.lo;
|
||||
let decl = parse_decl();
|
||||
let body = parse_body();
|
||||
let fakeblock = ast::blk_ {
|
||||
let fakeblock = ast::blk {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(body),
|
||||
id: self.get_id(),
|
||||
rules: default_blk,
|
||||
span: body.span,
|
||||
};
|
||||
let fakeblock = spanned(body.span.lo, body.span.hi,
|
||||
fakeblock);
|
||||
|
||||
return self.mk_expr(lo, body.span.hi,
|
||||
expr_fn_block(decl, fakeblock));
|
||||
}
|
||||
@ -2402,14 +2402,12 @@ impl Parser {
|
||||
self.eat(&token::COMMA);
|
||||
}
|
||||
|
||||
let blk = codemap::spanned {
|
||||
node: ast::blk_ {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: self.get_id(),
|
||||
rules: default_blk,
|
||||
},
|
||||
let blk = ast::blk {
|
||||
view_items: ~[],
|
||||
stmts: ~[],
|
||||
expr: Some(expr),
|
||||
id: self.get_id(),
|
||||
rules: default_blk,
|
||||
span: expr.span,
|
||||
};
|
||||
|
||||
@ -3120,14 +3118,14 @@ impl Parser {
|
||||
|
||||
let hi = self.span.hi;
|
||||
self.bump();
|
||||
let bloc = ast::blk_ {
|
||||
ast::blk {
|
||||
view_items: view_items,
|
||||
stmts: stmts,
|
||||
expr: expr,
|
||||
id: self.get_id(),
|
||||
rules: s,
|
||||
};
|
||||
spanned(lo, hi, bloc)
|
||||
span: mk_sp(lo, hi),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_optional_purity(&self) -> ast::purity {
|
||||
|
@ -932,7 +932,7 @@ pub fn print_possibly_embedded_block_(s: @ps,
|
||||
indented: uint,
|
||||
attrs: &[ast::attribute],
|
||||
close_box: bool) {
|
||||
match blk.node.rules {
|
||||
match blk.rules {
|
||||
ast::unsafe_blk => word_space(s, "unsafe"),
|
||||
ast::default_blk => ()
|
||||
}
|
||||
@ -946,11 +946,11 @@ pub fn print_possibly_embedded_block_(s: @ps,
|
||||
|
||||
print_inner_attributes(s, attrs);
|
||||
|
||||
for blk.node.view_items.iter().advance |vi| { print_view_item(s, vi); }
|
||||
for blk.node.stmts.iter().advance |st| {
|
||||
for blk.view_items.iter().advance |vi| { print_view_item(s, vi); }
|
||||
for blk.stmts.iter().advance |st| {
|
||||
print_stmt(s, *st);
|
||||
}
|
||||
match blk.node.expr {
|
||||
match blk.expr {
|
||||
Some(expr) => {
|
||||
space_if_not_bol(s);
|
||||
print_expr(s, expr);
|
||||
@ -1255,12 +1255,12 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
|
||||
|
||||
// Extract the expression from the extra block the parser adds
|
||||
// in the case of foo => expr
|
||||
if arm.body.node.view_items.is_empty() &&
|
||||
arm.body.node.stmts.is_empty() &&
|
||||
arm.body.node.rules == ast::default_blk &&
|
||||
arm.body.node.expr.is_some()
|
||||
if arm.body.view_items.is_empty() &&
|
||||
arm.body.stmts.is_empty() &&
|
||||
arm.body.rules == ast::default_blk &&
|
||||
arm.body.expr.is_some()
|
||||
{
|
||||
match arm.body.node.expr {
|
||||
match arm.body.expr {
|
||||
Some(expr) => {
|
||||
match expr.node {
|
||||
ast::expr_block(ref blk) => {
|
||||
@ -1297,16 +1297,16 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
|
||||
print_fn_block_args(s, decl);
|
||||
space(s.s);
|
||||
// }
|
||||
assert!(body.node.stmts.is_empty());
|
||||
assert!(body.node.expr.is_some());
|
||||
assert!(body.stmts.is_empty());
|
||||
assert!(body.expr.is_some());
|
||||
// we extract the block, so as not to create another set of boxes
|
||||
match body.node.expr.get().node {
|
||||
match body.expr.get().node {
|
||||
ast::expr_block(ref blk) => {
|
||||
print_block_unclosed(s, blk);
|
||||
}
|
||||
_ => {
|
||||
// this is a bare expression
|
||||
print_expr(s, body.node.expr.get());
|
||||
print_expr(s, body.expr.get());
|
||||
end(s); // need to close a box
|
||||
}
|
||||
}
|
||||
|
@ -413,13 +413,13 @@ pub fn visit_struct_field<E: Copy>(sf: &struct_field, (e, v): (E, vt<E>)) {
|
||||
}
|
||||
|
||||
pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) {
|
||||
for b.node.view_items.iter().advance |vi| {
|
||||
for b.view_items.iter().advance |vi| {
|
||||
(v.visit_view_item)(vi, (copy e, v));
|
||||
}
|
||||
for b.node.stmts.iter().advance |s| {
|
||||
for b.stmts.iter().advance |s| {
|
||||
(v.visit_stmt)(*s, (copy e, v));
|
||||
}
|
||||
visit_expr_opt(b.node.expr, (e, v));
|
||||
visit_expr_opt(b.expr, (e, v));
|
||||
}
|
||||
|
||||
pub fn visit_stmt<E>(s: &stmt, (e, v): (E, vt<E>)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user