Skip to content

Commit a9c4b18

Browse files
committed
Box Block, fn_decl, variant and Ty in the AST, as they were inflating critical enum sizes.
1 parent 80991bb commit a9c4b18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+623
-640
lines changed

src/librustc/front/config.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'self> fold::ast_fold for Context<'self> {
2727
fn fold_mod(&self, module: &ast::_mod) -> ast::_mod {
2828
fold_mod(self, module)
2929
}
30-
fn fold_block(&self, block: &ast::Block) -> ast::Block {
30+
fn fold_block(&self, block: ast::P<ast::Block>) -> ast::P<ast::Block> {
3131
fold_block(self, block)
3232
}
3333
fn fold_foreign_mod(&self, foreign_module: &ast::foreign_mod)
@@ -97,10 +97,10 @@ fn fold_foreign_mod(cx: &Context, nm: &ast::foreign_mod) -> ast::foreign_mod {
9797

9898
fn fold_item_underscore(cx: &Context, item: &ast::item_) -> ast::item_ {
9999
let item = match *item {
100-
ast::item_impl(ref a, ref b, ref c, ref methods) => {
100+
ast::item_impl(ref a, ref b, c, ref methods) => {
101101
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
102102
.map(|x| *x).collect();
103-
ast::item_impl((*a).clone(), (*b).clone(), (*c).clone(), methods)
103+
ast::item_impl((*a).clone(), (*b).clone(), c, methods)
104104
}
105105
ast::item_trait(ref a, ref b, ref methods) => {
106106
let methods = methods.iter()
@@ -129,22 +129,22 @@ fn retain_stmt(cx: &Context, stmt: @ast::Stmt) -> bool {
129129
}
130130
}
131131

132-
fn fold_block(cx: &Context, b: &ast::Block) -> ast::Block {
132+
fn fold_block(cx: &Context, b: ast::P<ast::Block>) -> ast::P<ast::Block> {
133133
let resulting_stmts = b.stmts.iter()
134134
.filter(|&a| retain_stmt(cx, *a))
135135
.flat_map(|&stmt| cx.fold_stmt(stmt).move_iter())
136136
.collect();
137137
let filtered_view_items = b.view_items.iter().filter_map(|a| {
138138
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
139139
}).collect();
140-
ast::Block {
140+
ast::P(ast::Block {
141141
view_items: filtered_view_items,
142142
stmts: resulting_stmts,
143143
expr: b.expr.map(|x| cx.fold_expr(x)),
144144
id: b.id,
145145
rules: b.rules,
146146
span: b.span,
147-
}
147+
})
148148
}
149149

150150
fn item_in_cfg(cx: &Context, item: @ast::item) -> bool {

src/librustc/metadata/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ fn encode_struct_fields(ecx: &EncodeContext,
351351
fn encode_enum_variant_info(ecx: &EncodeContext,
352352
ebml_w: &mut writer::Encoder,
353353
id: NodeId,
354-
variants: &[variant],
354+
variants: &[P<variant>],
355355
path: &[ast_map::path_elt],
356356
index: @mut ~[entry<i64>],
357357
generics: &ast::Generics) {
@@ -1080,7 +1080,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
10801080
def_id.node);
10811081
}
10821082
}
1083-
item_impl(_, ref opt_trait, ref ty, ref ast_methods) => {
1083+
item_impl(_, ref opt_trait, ty, ref ast_methods) => {
10841084
// We need to encode information about the default methods we
10851085
// have inherited, so we drive this based on the impl structure.
10861086
let imp = tcx.impls.get(&def_id);

src/librustc/middle/astencode.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct NestedItemsDropper {
301301
}
302302

303303
impl fold::ast_fold for NestedItemsDropper {
304-
fn fold_block(&self, blk: &ast::Block) -> ast::Block {
304+
fn fold_block(&self, blk: ast::P<ast::Block>) -> ast::P<ast::Block> {
305305
let stmts_sans_items = blk.stmts.iter().filter_map(|stmt| {
306306
match stmt.node {
307307
ast::StmtExpr(_, _) | ast::StmtSemi(_, _) |
@@ -316,16 +316,16 @@ impl fold::ast_fold for NestedItemsDropper {
316316
ast::StmtMac(..) => fail!("unexpanded macro in astencode")
317317
}
318318
}).collect();
319-
let blk_sans_items = ast::Block {
319+
let blk_sans_items = ast::P(ast::Block {
320320
view_items: ~[], // I don't know if we need the view_items here,
321321
// but it doesn't break tests!
322322
stmts: stmts_sans_items,
323323
expr: blk.expr,
324324
id: blk.id,
325325
rules: blk.rules,
326326
span: blk.span,
327-
};
328-
fold::noop_fold_block(&blk_sans_items, self)
327+
});
328+
fold::noop_fold_block(blk_sans_items, self)
329329
}
330330
}
331331

src/librustc/middle/borrowck/check_loans.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ impl<'self> Visitor<()> for CheckLoanCtxt<'self> {
4848
fn visit_local(&mut self, l:@ast::Local, _:()) {
4949
check_loans_in_local(self, l);
5050
}
51-
fn visit_block(&mut self, b:&ast::Block, _:()) {
51+
fn visit_block(&mut self, b:ast::P<ast::Block>, _:()) {
5252
check_loans_in_block(self, b);
5353
}
5454
fn visit_pat(&mut self, p:&ast::Pat, _:()) {
5555
check_loans_in_pat(self, p);
5656
}
5757
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
58-
b:&ast::Block, s:Span, n:ast::NodeId, _:()) {
58+
b:ast::P<ast::Block>, s:Span, n:ast::NodeId, _:()) {
5959
check_loans_in_fn(self, fk, fd, b, s, n);
6060
}
6161
}
@@ -64,7 +64,7 @@ pub fn check_loans(bccx: &BorrowckCtxt,
6464
dfcx_loans: &LoanDataFlow,
6565
move_data: move_data::FlowedMoveData,
6666
all_loans: &[Loan],
67-
body: &ast::Block) {
67+
body: ast::P<ast::Block>) {
6868
debug!("check_loans(body id={:?})", body.id);
6969

7070
let mut clcx = CheckLoanCtxt {
@@ -724,7 +724,7 @@ impl<'self> CheckLoanCtxt<'self> {
724724
fn check_loans_in_fn<'a>(this: &mut CheckLoanCtxt<'a>,
725725
fk: &visit::fn_kind,
726726
decl: &ast::fn_decl,
727-
body: &ast::Block,
727+
body: ast::P<ast::Block>,
728728
sp: Span,
729729
id: ast::NodeId) {
730730
match *fk {
@@ -855,7 +855,7 @@ fn check_loans_in_pat<'a>(this: &mut CheckLoanCtxt<'a>,
855855
}
856856

857857
fn check_loans_in_block<'a>(this: &mut CheckLoanCtxt<'a>,
858-
blk: &ast::Block)
858+
blk: ast::P<ast::Block>)
859859
{
860860
visit::walk_block(this, blk, ());
861861
this.check_for_conflicting_loans(blk.id);

src/librustc/middle/borrowck/gather_loans/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syntax::codemap::Span;
3232
use syntax::print::pprust;
3333
use syntax::visit;
3434
use syntax::visit::{Visitor, fn_kind};
35-
use syntax::ast::{Expr, fn_decl, Block, NodeId, Stmt, Pat, Local};
35+
use syntax::ast::{P, Expr, fn_decl, Block, NodeId, Stmt, Pat, Local};
3636

3737
mod lifetime;
3838
mod restrictions;
@@ -77,10 +77,10 @@ impl<'self> visit::Visitor<()> for GatherLoanCtxt<'self> {
7777
fn visit_expr(&mut self, ex:@Expr, _:()) {
7878
gather_loans_in_expr(self, ex);
7979
}
80-
fn visit_block(&mut self, b:&Block, _:()) {
80+
fn visit_block(&mut self, b:P<Block>, _:()) {
8181
gather_loans_in_block(self, b);
8282
}
83-
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block,
83+
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:P<Block>,
8484
s:Span, n:NodeId, _:()) {
8585
gather_loans_in_fn(self, fk, fd, b, s, n);
8686
}
@@ -102,7 +102,7 @@ impl<'self> visit::Visitor<()> for GatherLoanCtxt<'self> {
102102

103103
pub fn gather_loans(bccx: &BorrowckCtxt,
104104
decl: &ast::fn_decl,
105-
body: &ast::Block)
105+
body: ast::P<ast::Block>)
106106
-> (id_range, @mut ~[Loan], @mut move_data::MoveData) {
107107
let mut glcx = GatherLoanCtxt {
108108
bccx: bccx,
@@ -131,7 +131,7 @@ fn add_pat_to_id_range(this: &mut GatherLoanCtxt,
131131
fn gather_loans_in_fn(this: &mut GatherLoanCtxt,
132132
fk: &fn_kind,
133133
decl: &ast::fn_decl,
134-
body: &ast::Block,
134+
body: ast::P<ast::Block>,
135135
sp: Span,
136136
id: ast::NodeId) {
137137
match fk {
@@ -150,7 +150,7 @@ fn gather_loans_in_fn(this: &mut GatherLoanCtxt,
150150
}
151151

152152
fn gather_loans_in_block(this: &mut GatherLoanCtxt,
153-
blk: &ast::Block) {
153+
blk: ast::P<ast::Block>) {
154154
this.id_range.add(blk.id);
155155
visit::walk_block(this, blk, ());
156156
}
@@ -286,7 +286,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
286286
}
287287

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

301301
// see explanation attached to the `root_ub` field:
302-
ast::ExprLoop(ref body, _) => {
302+
ast::ExprLoop(body, _) => {
303303
this.push_repeating_id(body.id);
304304
visit::walk_expr(this, ex, ());
305305
this.pop_repeating_id(body.id);

src/librustc/middle/borrowck/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax::codemap::Span;
2929
use syntax::parse::token;
3030
use syntax::visit;
3131
use syntax::visit::{Visitor,fn_kind};
32-
use syntax::ast::{fn_decl,Block,NodeId};
32+
use syntax::ast::{P,fn_decl,Block,NodeId};
3333

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

6363
impl Visitor<()> for BorrowckCtxt {
6464
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl,
65-
b:&Block, s:Span, n:NodeId, _:()) {
65+
b:P<Block>, s:Span, n:NodeId, _:()) {
6666
borrowck_fn(self, fk, fd, b, s, n);
6767
}
6868
}
@@ -123,7 +123,7 @@ pub fn check_crate(
123123
fn borrowck_fn(this: &mut BorrowckCtxt,
124124
fk: &visit::fn_kind,
125125
decl: &ast::fn_decl,
126-
body: &ast::Block,
126+
body: ast::P<ast::Block>,
127127
sp: Span,
128128
id: ast::NodeId) {
129129
match fk {

src/librustc/middle/cfg/construct.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ impl CFGBuilder {
161161

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

169-
ast::ExprIf(cond, ref then, None) => {
169+
ast::ExprIf(cond, then, None) => {
170170
//
171171
// [pred]
172172
// |
@@ -186,7 +186,7 @@ impl CFGBuilder {
186186
self.add_node(expr.id, [cond_exit, then_exit]) // 3,4
187187
}
188188

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

210-
ast::ExprWhile(cond, ref body) => {
210+
ast::ExprWhile(cond, body) => {
211211
//
212212
// [pred]
213213
// |
@@ -241,7 +241,7 @@ impl CFGBuilder {
241241

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

244-
ast::ExprLoop(ref body, _) => {
244+
ast::ExprLoop(body, _) => {
245245
//
246246
// [pred]
247247
// |
@@ -300,7 +300,7 @@ impl CFGBuilder {
300300
for arm in arms.iter() {
301301
guard_exit = self.opt_expr(arm.guard, guard_exit); // 2
302302
let pats_exit = self.pats_any(arm.pats, guard_exit); // 3
303-
let body_exit = self.block(&arm.body, pats_exit); // 4
303+
let body_exit = self.block(arm.body, pats_exit); // 4
304304
self.add_contained_edge(body_exit, expr_exit); // 5
305305
}
306306
expr_exit

src/librustc/middle/check_loop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ impl Visitor<Context> for CheckLoopVisitor {
3535

3636
fn visit_expr(&mut self, e: @ast::Expr, cx:Context) {
3737
match e.node {
38-
ast::ExprWhile(e, ref b) => {
38+
ast::ExprWhile(e, b) => {
3939
self.visit_expr(e, cx);
4040
self.visit_block(b, Loop);
4141
}
42-
ast::ExprLoop(ref b, _) => {
42+
ast::ExprLoop(b, _) => {
4343
self.visit_block(b, Loop);
4444
}
45-
ast::ExprFnBlock(_, ref b) | ast::ExprProc(_, ref b) => {
45+
ast::ExprFnBlock(_, b) | ast::ExprProc(_, b) => {
4646
self.visit_block(b, Closure);
4747
}
4848
ast::ExprBreak(_) => self.require_loop("break", cx, e.span),

src/librustc/middle/check_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Visitor<()> for CheckMatchVisitor {
4545
fn visit_local(&mut self, l:@Local, e:()) {
4646
check_local(self, self.cx, l, e);
4747
}
48-
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:&Block, s:Span, n:NodeId, e:()) {
48+
fn visit_fn(&mut self, fk:&fn_kind, fd:&fn_decl, b:P<Block>, s:Span, n:NodeId, e:()) {
4949
check_fn(self, self.cx, fk, fd, b, s, n, e);
5050
}
5151
}
@@ -827,7 +827,7 @@ fn check_fn(v: &mut CheckMatchVisitor,
827827
cx: &MatchCheckCtxt,
828828
kind: &visit::fn_kind,
829829
decl: &fn_decl,
830-
body: &Block,
830+
body: P<Block>,
831831
sp: Span,
832832
id: NodeId,
833833
s: ()) {

src/librustc/middle/const_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
9090
enum_def: ast::DefId,
9191
variant_def: ast::DefId)
9292
-> Option<@Expr> {
93-
fn variant_expr(variants: &[ast::variant], id: ast::NodeId) -> Option<@Expr> {
93+
fn variant_expr(variants: &[ast::P<ast::variant>], id: ast::NodeId) -> Option<@Expr> {
9494
for variant in variants.iter() {
9595
if variant.node.id == id {
9696
return variant.node.disr_expr;

src/librustc/middle/dataflow.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
429429
self.merge_with_entry_set(expr.id, in_out);
430430

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

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

545-
ast::ExprWhile(cond, ref blk) => {
545+
ast::ExprWhile(cond, blk) => {
546546
//
547547
// (expr) <--+
548548
// | |
@@ -570,7 +570,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
570570

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

573-
ast::ExprLoop(ref blk, _) => {
573+
ast::ExprLoop(blk, _) => {
574574
//
575575
// (expr) <--+
576576
// | |
@@ -623,7 +623,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
623623
// them into `in_out`, which reflects all bodies to date
624624
let mut body = reslice(guards).to_owned();
625625
self.walk_pat_alternatives(arm.pats, body, loop_scopes);
626-
self.walk_block(&arm.body, body, loop_scopes);
626+
self.walk_block(arm.body, body, loop_scopes);
627627
join_bits(&self.dfcx.oper, body, in_out);
628628
}
629629
}
@@ -730,7 +730,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
730730
}
731731
}
732732

733-
ast::ExprBlock(ref blk) => {
733+
ast::ExprBlock(blk) => {
734734
self.walk_block(blk, in_out, loop_scopes);
735735
}
736736

0 commit comments

Comments
 (0)