Skip to content

Commit f223b2c

Browse files
committed
Allocate HIR with arenas
1 parent 21acf1e commit f223b2c

Some content is hidden

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

89 files changed

+2173
-1775
lines changed

src/bootstrap/bin/rustc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ fn main() {
312312
{
313313
cmd.arg("-Dwarnings");
314314
cmd.arg("-Dbare_trait_objects");
315-
cmd.arg("-Drust_2018_idioms");
315+
// FIXME(@Zoxc): Turn back on
316+
//cmd.arg("-Drust_2018_idioms");
316317
}
317318

318319
if verbose > 1 {

src/librustc/arena.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ macro_rules! arena_types {
3131
rustc::hir::def_id::DefId,
3232
rustc::ty::subst::SubstsRef<$tcx>
3333
)>,
34-
[few] lowered_hir: rustc::hir::LoweredHir,
34+
[] lits: syntax::source_map::Spanned<syntax::ast::LitKind>,
35+
[] attrs: syntax::ast::Attribute,
36+
[few] token_streams: syntax::tokenstream::TokenStream,
37+
[few] inline_asm: rustc::hir::InlineAsm,
38+
[few] lowered_hir: rustc::hir::LoweredHir<$tcx>,
3539
[few] hir_map: rustc::hir::map::Map<$tcx>,
3640
[few, decode] mir_keys: rustc::util::nodemap::DefIdSet,
3741
[decode] specialization_graph: rustc::traits::specialization_graph::Graph,

src/librustc/cfg/construct.rs

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::cfg::*;
22
use crate::middle::region;
33
use rustc_data_structures::graph::implementation as graph;
4-
use syntax::ptr::P;
54
use crate::ty::{self, TyCtxt};
65

6+
use crate::hir::ptr::P;
77
use crate::hir::{self, PatKind};
88
use crate::hir::def_id::DefId;
99

@@ -66,7 +66,7 @@ pub fn construct<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body) -> CFG {
6666
}
6767

6868
impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
69-
fn block(&mut self, blk: &hir::Block, pred: CFGIndex) -> CFGIndex {
69+
fn block(&mut self, blk: &hir::Block<'_>, pred: CFGIndex) -> CFGIndex {
7070
if blk.targeted_by_break {
7171
let expr_exit = self.add_ast_node(blk.hir_id.local_id, &[]);
7272

@@ -97,7 +97,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
9797
}
9898
}
9999

100-
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
100+
fn stmt(&mut self, stmt: &hir::Stmt<'_>, pred: CFGIndex) -> CFGIndex {
101101
let exit = match stmt.node {
102102
hir::StmtKind::Local(ref local) => {
103103
let init_exit = self.opt_expr(&local.init, pred);
@@ -114,7 +114,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
114114
self.add_ast_node(stmt.hir_id.local_id, &[exit])
115115
}
116116

117-
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
117+
fn pat(&mut self, pat: &hir::Pat<'_>, pred: CFGIndex) -> CFGIndex {
118118
match pat.node {
119119
PatKind::Binding(.., None) |
120120
PatKind::Path(_) |
@@ -149,16 +149,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
149149
}
150150
}
151151

152-
fn pats_all<'b, I: Iterator<Item=&'b P<hir::Pat>>>(
153-
&mut self,
154-
pats: I,
155-
pred: CFGIndex
156-
) -> CFGIndex {
152+
fn pats_all<'b, 'h: 'b, I: Iterator<Item=&'b P<'h, hir::Pat<'h>>>>(&mut self,
153+
pats: I,
154+
pred: CFGIndex) -> CFGIndex {
157155
//! Handles case where all of the patterns must match.
158156
pats.fold(pred, |pred, pat| self.pat(&pat, pred))
159157
}
160158

161-
fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex {
159+
fn expr(&mut self, expr: &hir::Expr<'_>, pred: CFGIndex) -> CFGIndex {
162160
match expr.node {
163161
hir::ExprKind::Block(ref blk, _) => {
164162
let blk_exit = self.block(&blk, pred);
@@ -297,7 +295,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
297295

298296
hir::ExprKind::Index(ref l, ref r) |
299297
hir::ExprKind::Binary(_, ref l, ref r) if self.tables.is_method_call(expr) => {
300-
self.call(expr, pred, &l, Some(&**r).into_iter())
298+
self.call(expr, pred, &l, Some(&***r).into_iter())
301299
}
302300

303301
hir::ExprKind::Unary(_, ref e) if self.tables.is_method_call(expr) => {
@@ -309,18 +307,18 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
309307
}
310308

311309
hir::ExprKind::Struct(_, ref fields, ref base) => {
312-
let field_cfg = self.straightline(expr, pred, fields.iter().map(|f| &*f.expr));
310+
let field_cfg = self.straightline(expr, pred, fields.iter().map(|f| &**f.expr));
313311
self.opt_expr(base, field_cfg)
314312
}
315313

316314
hir::ExprKind::Assign(ref l, ref r) |
317315
hir::ExprKind::AssignOp(_, ref l, ref r) => {
318-
self.straightline(expr, pred, [r, l].iter().map(|&e| &**e))
316+
self.straightline(expr, pred, [r, l].iter().map(|&e| &***e))
319317
}
320318

321319
hir::ExprKind::Index(ref l, ref r) |
322320
hir::ExprKind::Binary(_, ref l, ref r) => { // N.B., && and || handled earlier
323-
self.straightline(expr, pred, [l, r].iter().map(|&e| &**e))
321+
self.straightline(expr, pred, [l, r].iter().map(|&e| &***e))
324322
}
325323

326324
hir::ExprKind::Box(ref e) |
@@ -332,7 +330,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
332330
hir::ExprKind::Field(ref e, _) |
333331
hir::ExprKind::Yield(ref e) |
334332
hir::ExprKind::Repeat(ref e, _) => {
335-
self.straightline(expr, pred, Some(&**e).into_iter())
333+
self.straightline(expr, pred, Some(&***e).into_iter())
336334
}
337335

338336
hir::ExprKind::InlineAsm(_, ref outputs, ref inputs) => {
@@ -350,10 +348,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
350348
}
351349
}
352350

353-
fn call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
354-
call_expr: &hir::Expr,
351+
fn call<'b, 'h: 'b, I: Iterator<Item=&'b hir::Expr<'h>>>(&mut self,
352+
call_expr: &hir::Expr<'_>,
355353
pred: CFGIndex,
356-
func_or_rcvr: &hir::Expr,
354+
func_or_rcvr: &hir::Expr<'_>,
357355
args: I) -> CFGIndex {
358356
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
359357
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
@@ -365,22 +363,22 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
365363
}
366364
}
367365

368-
fn exprs<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
366+
fn exprs<'b, 'h: 'b, I: Iterator<Item=&'b hir::Expr<'h>>>(&mut self,
369367
exprs: I,
370368
pred: CFGIndex) -> CFGIndex {
371369
//! Constructs graph for `exprs` evaluated in order
372370
exprs.fold(pred, |p, e| self.expr(e, p))
373371
}
374372

375373
fn opt_expr(&mut self,
376-
opt_expr: &Option<P<hir::Expr>>,
374+
opt_expr: &Option<P<'_, hir::Expr<'_>>>,
377375
pred: CFGIndex) -> CFGIndex {
378376
//! Constructs graph for `opt_expr` evaluated, if Some
379377
opt_expr.iter().fold(pred, |p, e| self.expr(&e, p))
380378
}
381379

382-
fn straightline<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
383-
expr: &hir::Expr,
380+
fn straightline<'b, 'h: 'b, I: Iterator<Item=&'b hir::Expr<'h>>>(&mut self,
381+
expr: &hir::Expr<'_>,
384382
pred: CFGIndex,
385383
subexprs: I) -> CFGIndex {
386384
//! Handles case of an expression that evaluates `subexprs` in order
@@ -389,8 +387,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
389387
self.add_ast_node(expr.hir_id.local_id, &[subexprs_exit])
390388
}
391389

392-
fn match_(&mut self, id: hir::ItemLocalId, discr: &hir::Expr,
393-
arms: &[hir::Arm], pred: CFGIndex) -> CFGIndex {
390+
fn match_(&mut self, id: hir::ItemLocalId, discr: &hir::Expr<'_>,
391+
arms: &[hir::Arm<'_>], pred: CFGIndex) -> CFGIndex {
394392
// The CFG for match expression is quite complex, so no ASCII
395393
// art for it (yet).
396394
//
@@ -495,7 +493,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
495493
}
496494

497495
fn add_exiting_edge(&mut self,
498-
from_expr: &hir::Expr,
496+
from_expr: &hir::Expr<'_>,
499497
from_index: CFGIndex,
500498
target_scope: region::Scope,
501499
to_index: CFGIndex) {
@@ -513,7 +511,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
513511
}
514512

515513
fn add_returning_edge(&mut self,
516-
_from_expr: &hir::Expr,
514+
_from_expr: &hir::Expr<'_>,
517515
from_index: CFGIndex) {
518516
let data = CFGEdgeData {
519517
exiting_scopes: self.loop_scopes.iter()
@@ -525,7 +523,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
525523
}
526524

527525
fn find_scope_edge(&self,
528-
expr: &hir::Expr,
526+
expr: &hir::Expr<'_>,
529527
destination: hir::Destination,
530528
scope_cf_kind: ScopeCfKind) -> (region::Scope, CFGIndex) {
531529

0 commit comments

Comments
 (0)