Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box Block, fn_decl, variant and Ty in the AST. #10676

Merged
merged 1 commit into from
Dec 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'self> fold::ast_fold for Context<'self> {
fn fold_mod(&self, module: &ast::_mod) -> ast::_mod {
fold_mod(self, module)
}
fn fold_block(&self, block: &ast::Block) -> ast::Block {
fn fold_block(&self, block: ast::P<ast::Block>) -> ast::P<ast::Block> {
fold_block(self, block)
}
fn fold_foreign_mod(&self, foreign_module: &ast::foreign_mod)
Expand Down Expand Up @@ -97,10 +97,10 @@ fn fold_foreign_mod(cx: &Context, nm: &ast::foreign_mod) -> ast::foreign_mod {

fn fold_item_underscore(cx: &Context, item: &ast::item_) -> ast::item_ {
let item = match *item {
ast::item_impl(ref a, ref b, ref c, ref methods) => {
ast::item_impl(ref a, ref b, c, ref methods) => {
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
.map(|x| *x).collect();
ast::item_impl((*a).clone(), (*b).clone(), (*c).clone(), methods)
ast::item_impl((*a).clone(), (*b).clone(), c, methods)
}
ast::item_trait(ref a, ref b, ref methods) => {
let methods = methods.iter()
Expand Down Expand Up @@ -129,22 +129,22 @@ fn retain_stmt(cx: &Context, stmt: @ast::Stmt) -> bool {
}
}

fn fold_block(cx: &Context, b: &ast::Block) -> ast::Block {
fn fold_block(cx: &Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
let resulting_stmts = b.stmts.iter()
.filter(|&a| retain_stmt(cx, *a))
.flat_map(|&stmt| cx.fold_stmt(stmt).move_iter())
.collect();
let filtered_view_items = b.view_items.iter().filter_map(|a| {
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
}).collect();
ast::Block {
ast::P(ast::Block {
view_items: filtered_view_items,
stmts: resulting_stmts,
expr: b.expr.map(|x| cx.fold_expr(x)),
id: b.id,
rules: b.rules,
span: b.span,
}
})
}

fn item_in_cfg(cx: &Context, item: @ast::item) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn encode_struct_fields(ecx: &EncodeContext,
fn encode_enum_variant_info(ecx: &EncodeContext,
ebml_w: &mut writer::Encoder,
id: NodeId,
variants: &[variant],
variants: &[P<variant>],
path: &[ast_map::path_elt],
index: @mut ~[entry<i64>],
generics: &ast::Generics) {
Expand Down Expand Up @@ -1080,7 +1080,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
def_id.node);
}
}
item_impl(_, ref opt_trait, ref ty, ref ast_methods) => {
item_impl(_, ref opt_trait, ty, ref ast_methods) => {
// We need to encode information about the default methods we
// have inherited, so we drive this based on the impl structure.
let imp = tcx.impls.get(&def_id);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct NestedItemsDropper {
}

impl fold::ast_fold for NestedItemsDropper {
fn fold_block(&self, blk: &ast::Block) -> ast::Block {
fn fold_block(&self, blk: ast::P<ast::Block>) -> ast::P<ast::Block> {
let stmts_sans_items = blk.stmts.iter().filter_map(|stmt| {
match stmt.node {
ast::StmtExpr(_, _) | ast::StmtSemi(_, _) |
Expand All @@ -316,16 +316,16 @@ impl fold::ast_fold for NestedItemsDropper {
ast::StmtMac(..) => fail!("unexpanded macro in astencode")
}
}).collect();
let blk_sans_items = ast::Block {
let blk_sans_items = ast::P(ast::Block {
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,
span: blk.span,
};
fold::noop_fold_block(&blk_sans_items, self)
});
fold::noop_fold_block(blk_sans_items, self)
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ impl<'self> Visitor<()> for CheckLoanCtxt<'self> {
fn visit_local(&mut self, l:@ast::Local, _:()) {
check_loans_in_local(self, l);
}
fn visit_block(&mut self, b:&ast::Block, _:()) {
fn visit_block(&mut self, b:ast::P<ast::Block>, _:()) {
check_loans_in_block(self, b);
}
fn visit_pat(&mut self, p:&ast::Pat, _:()) {
check_loans_in_pat(self, p);
}
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
b:&ast::Block, s:Span, n:ast::NodeId, _:()) {
b:ast::P<ast::Block>, s:Span, n:ast::NodeId, _:()) {
check_loans_in_fn(self, fk, fd, b, s, n);
}
}
Expand All @@ -64,7 +64,7 @@ pub fn check_loans(bccx: &BorrowckCtxt,
dfcx_loans: &LoanDataFlow,
move_data: move_data::FlowedMoveData,
all_loans: &[Loan],
body: &ast::Block) {
body: ast::P<ast::Block>) {
debug!("check_loans(body id={:?})", body.id);

let mut clcx = CheckLoanCtxt {
Expand Down Expand Up @@ -724,7 +724,7 @@ impl<'self> CheckLoanCtxt<'self> {
fn check_loans_in_fn<'a>(this: &mut CheckLoanCtxt<'a>,
fk: &visit::fn_kind,
decl: &ast::fn_decl,
body: &ast::Block,
body: ast::P<ast::Block>,
sp: Span,
id: ast::NodeId) {
match *fk {
Expand Down Expand Up @@ -855,7 +855,7 @@ fn check_loans_in_pat<'a>(this: &mut CheckLoanCtxt<'a>,
}

fn check_loans_in_block<'a>(this: &mut CheckLoanCtxt<'a>,
blk: &ast::Block)
blk: ast::P<ast::Block>)
{
visit::walk_block(this, blk, ());
this.check_for_conflicting_loans(blk.id);
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/middle/borrowck/gather_loans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use syntax::codemap::Span;
use syntax::print::pprust;
use syntax::visit;
use syntax::visit::{Visitor, fn_kind};
use syntax::ast::{Expr, fn_decl, Block, NodeId, Stmt, Pat, Local};
use syntax::ast::{P, Expr, fn_decl, Block, NodeId, Stmt, Pat, Local};

mod lifetime;
mod restrictions;
Expand Down Expand Up @@ -77,10 +77,10 @@ impl<'self> visit::Visitor<()> for GatherLoanCtxt<'self> {
fn visit_expr(&mut self, ex:@Expr, _:()) {
gather_loans_in_expr(self, ex);
}
fn visit_block(&mut self, b:&Block, _:()) {
fn visit_block(&mut self, b:P<Block>, _:()) {
gather_loans_in_block(self, b);
}
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block,
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:P<Block>,
s:Span, n:NodeId, _:()) {
gather_loans_in_fn(self, fk, fd, b, s, n);
}
Expand All @@ -102,7 +102,7 @@ impl<'self> visit::Visitor<()> for GatherLoanCtxt<'self> {

pub fn gather_loans(bccx: &BorrowckCtxt,
decl: &ast::fn_decl,
body: &ast::Block)
body: ast::P<ast::Block>)
-> (id_range, @mut ~[Loan], @mut move_data::MoveData) {
let mut glcx = GatherLoanCtxt {
bccx: bccx,
Expand Down Expand Up @@ -131,7 +131,7 @@ fn add_pat_to_id_range(this: &mut GatherLoanCtxt,
fn gather_loans_in_fn(this: &mut GatherLoanCtxt,
fk: &fn_kind,
decl: &ast::fn_decl,
body: &ast::Block,
body: ast::P<ast::Block>,
sp: Span,
id: ast::NodeId) {
match fk {
Expand All @@ -150,7 +150,7 @@ fn gather_loans_in_fn(this: &mut GatherLoanCtxt,
}

fn gather_loans_in_block(this: &mut GatherLoanCtxt,
blk: &ast::Block) {
blk: ast::P<ast::Block>) {
this.id_range.add(blk.id);
visit::walk_block(this, blk, ());
}
Expand Down Expand Up @@ -286,7 +286,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
}

// see explanation attached to the `root_ub` field:
ast::ExprWhile(cond, ref body) => {
ast::ExprWhile(cond, body) => {
// during the condition, can only root for the condition
this.push_repeating_id(cond.id);
this.visit_expr(cond, ());
Expand All @@ -299,7 +299,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
}

// see explanation attached to the `root_ub` field:
ast::ExprLoop(ref body, _) => {
ast::ExprLoop(body, _) => {
this.push_repeating_id(body.id);
visit::walk_expr(this, ex, ());
this.pop_repeating_id(body.id);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use syntax::codemap::Span;
use syntax::parse::token;
use syntax::visit;
use syntax::visit::{Visitor,fn_kind};
use syntax::ast::{fn_decl,Block,NodeId};
use syntax::ast::{P,fn_decl,Block,NodeId};

macro_rules! if_ok(
($inp: expr) => (
Expand Down Expand Up @@ -62,7 +62,7 @@ pub type LoanDataFlow = DataFlowContext<LoanDataFlowOperator>;

impl Visitor<()> for BorrowckCtxt {
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl,
b:&Block, s:Span, n:NodeId, _:()) {
b:P<Block>, s:Span, n:NodeId, _:()) {
borrowck_fn(self, fk, fd, b, s, n);
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ pub fn check_crate(
fn borrowck_fn(this: &mut BorrowckCtxt,
fk: &visit::fn_kind,
decl: &ast::fn_decl,
body: &ast::Block,
body: ast::P<ast::Block>,
sp: Span,
id: ast::NodeId) {
match fk {
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ impl CFGBuilder {

fn expr(&mut self, expr: @ast::Expr, pred: CFGIndex) -> CFGIndex {
match expr.node {
ast::ExprBlock(ref blk) => {
ast::ExprBlock(blk) => {
let blk_exit = self.block(blk, pred);
self.add_node(expr.id, [blk_exit])
}

ast::ExprIf(cond, ref then, None) => {
ast::ExprIf(cond, then, None) => {
//
// [pred]
// |
Expand All @@ -186,7 +186,7 @@ impl CFGBuilder {
self.add_node(expr.id, [cond_exit, then_exit]) // 3,4
}

ast::ExprIf(cond, ref then, Some(otherwise)) => {
ast::ExprIf(cond, then, Some(otherwise)) => {
//
// [pred]
// |
Expand All @@ -207,7 +207,7 @@ impl CFGBuilder {
self.add_node(expr.id, [then_exit, else_exit]) // 4, 5
}

ast::ExprWhile(cond, ref body) => {
ast::ExprWhile(cond, body) => {
//
// [pred]
// |
Expand Down Expand Up @@ -241,7 +241,7 @@ impl CFGBuilder {

ast::ExprForLoop(..) => fail!("non-desugared expr_for_loop"),

ast::ExprLoop(ref body, _) => {
ast::ExprLoop(body, _) => {
//
// [pred]
// |
Expand Down Expand Up @@ -300,7 +300,7 @@ impl CFGBuilder {
for arm in arms.iter() {
guard_exit = self.opt_expr(arm.guard, guard_exit); // 2
let pats_exit = self.pats_any(arm.pats, guard_exit); // 3
let body_exit = self.block(&arm.body, pats_exit); // 4
let body_exit = self.block(arm.body, pats_exit); // 4
self.add_contained_edge(body_exit, expr_exit); // 5
}
expr_exit
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/check_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ impl Visitor<Context> for CheckLoopVisitor {

fn visit_expr(&mut self, e: @ast::Expr, cx:Context) {
match e.node {
ast::ExprWhile(e, ref b) => {
ast::ExprWhile(e, b) => {
self.visit_expr(e, cx);
self.visit_block(b, Loop);
}
ast::ExprLoop(ref b, _) => {
ast::ExprLoop(b, _) => {
self.visit_block(b, Loop);
}
ast::ExprFnBlock(_, ref b) | ast::ExprProc(_, ref b) => {
ast::ExprFnBlock(_, b) | ast::ExprProc(_, b) => {
self.visit_block(b, Closure);
}
ast::ExprBreak(_) => self.require_loop("break", cx, e.span),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Visitor<()> for CheckMatchVisitor {
fn visit_local(&mut self, l:@Local, e:()) {
check_local(self, self.cx, l, e);
}
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:()) {
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:P<Block>, s:Span, n:NodeId, e:()) {
check_fn(self, self.cx, fk, fd, b, s, n, e);
}
}
Expand Down Expand Up @@ -827,7 +827,7 @@ fn check_fn(v: &mut CheckMatchVisitor,
cx: &MatchCheckCtxt,
kind: &visit::fn_kind,
decl: &fn_decl,
body: &Block,
body: P<Block>,
sp: Span,
id: NodeId,
s: ()) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
enum_def: ast::DefId,
variant_def: ast::DefId)
-> Option<@Expr> {
fn variant_expr(variants: &[ast::variant], id: ast::NodeId) -> Option<@Expr> {
fn variant_expr(variants: &[ast::P<ast::variant>], id: ast::NodeId) -> Option<@Expr> {
for variant in variants.iter() {
if variant.node.id == id {
return variant.node.disr_expr;
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
self.merge_with_entry_set(expr.id, in_out);

match expr.node {
ast::ExprFnBlock(ref decl, ref body) |
ast::ExprProc(ref decl, ref body) => {
ast::ExprFnBlock(ref decl, body) |
ast::ExprProc(ref decl, body) => {
if self.dfcx.oper.walk_closures() {
// In the absence of once fns, we must assume that
// every function body will execute more than
Expand Down Expand Up @@ -519,7 +519,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
}
}

ast::ExprIf(cond, ref then, els) => {
ast::ExprIf(cond, then, els) => {
//
// (cond)
// |
Expand All @@ -542,7 +542,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
join_bits(&self.dfcx.oper, then_bits, in_out);
}

ast::ExprWhile(cond, ref blk) => {
ast::ExprWhile(cond, blk) => {
//
// (expr) <--+
// | |
Expand Down Expand Up @@ -570,7 +570,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {

ast::ExprForLoop(..) => fail!("non-desugared expr_for_loop"),

ast::ExprLoop(ref blk, _) => {
ast::ExprLoop(blk, _) => {
//
// (expr) <--+
// | |
Expand Down Expand Up @@ -623,7 +623,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
// them into `in_out`, which reflects all bodies to date
let mut body = reslice(guards).to_owned();
self.walk_pat_alternatives(arm.pats, body, loop_scopes);
self.walk_block(&arm.body, body, loop_scopes);
self.walk_block(arm.body, body, loop_scopes);
join_bits(&self.dfcx.oper, body, in_out);
}
}
Expand Down Expand Up @@ -730,7 +730,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
}
}

ast::ExprBlock(ref blk) => {
ast::ExprBlock(blk) => {
self.walk_block(blk, in_out, loop_scopes);
}

Expand Down
Loading