@@ -50,6 +50,7 @@ use std::mem;
50
50
use std:: ops;
51
51
use std:: rc:: Rc ;
52
52
use std:: collections:: { HashMap , HashSet } ;
53
+ use arena:: TypedArena ;
53
54
use syntax:: abi;
54
55
use syntax:: ast:: { CrateNum , DefId , FnStyle , Ident , ItemTrait , LOCAL_CRATE } ;
55
56
use syntax:: ast:: { MutImmutable , MutMutable , Name , NamedField , NodeId } ;
@@ -410,10 +411,13 @@ pub struct TransmuteRestriction {
410
411
/// The data structure to keep track of all the information that typechecker
411
412
/// generates so that so that it can be reused and doesn't have to be redone
412
413
/// later on.
413
- pub struct ctxt {
414
+ pub struct ctxt < ' tcx > {
415
+ /// The arena that types are allocated from.
416
+ type_arena : & ' tcx TypedArena < t_box_ > ,
417
+
414
418
/// Specifically use a speedy hash algorithm for this hash map, it's used
415
419
/// quite often.
416
- pub interner : RefCell < FnvHashMap < intern_key , Box < t_box_ > > > ,
420
+ interner : RefCell < FnvHashMap < intern_key , & ' tcx t_box_ > > ,
417
421
pub next_id : Cell < uint > ,
418
422
pub sess : Session ,
419
423
pub def_map : resolve:: DefMap ,
@@ -1365,21 +1369,22 @@ impl UnboxedClosureKind {
1365
1369
}
1366
1370
}
1367
1371
1368
- pub fn mk_ctxt ( s : Session ,
1369
- dm : resolve :: DefMap ,
1370
- named_region_map : resolve_lifetime :: NamedRegionMap ,
1371
- map : ast_map :: Map ,
1372
- freevars : freevars :: freevar_map ,
1373
- capture_modes : freevars:: CaptureModeMap ,
1374
- region_maps : middle :: region :: RegionMaps ,
1375
- lang_items : middle:: lang_items :: LanguageItems ,
1376
- stability : stability :: Index )
1377
- -> ctxt {
1372
+ pub fn mk_ctxt < ' tcx > ( s : Session ,
1373
+ type_arena : & ' tcx TypedArena < t_box_ > ,
1374
+ dm : resolve :: DefMap ,
1375
+ named_region_map : resolve_lifetime :: NamedRegionMap ,
1376
+ map : ast_map :: Map ,
1377
+ freevars : freevars:: freevar_map ,
1378
+ capture_modes : freevars :: CaptureModeMap ,
1379
+ region_maps : middle:: region :: RegionMaps ,
1380
+ lang_items : middle :: lang_items :: LanguageItems ,
1381
+ stability : stability :: Index ) -> ctxt < ' tcx > {
1378
1382
ctxt {
1383
+ type_arena : type_arena,
1384
+ interner : RefCell :: new ( FnvHashMap :: new ( ) ) ,
1379
1385
named_region_map : named_region_map,
1380
1386
item_variance_map : RefCell :: new ( DefIdMap :: new ( ) ) ,
1381
1387
variance_computed : Cell :: new ( false ) ,
1382
- interner : RefCell :: new ( FnvHashMap :: new ( ) ) ,
1383
1388
next_id : Cell :: new ( primitives:: LAST_PRIMITIVE_ID ) ,
1384
1389
sess : s,
1385
1390
def_map : dm,
@@ -1546,11 +1551,11 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
1546
1551
}
1547
1552
}
1548
1553
1549
- let t = box t_box_ {
1554
+ let t = cx . type_arena . alloc ( t_box_ {
1550
1555
sty : st,
1551
1556
id : cx. next_id . get ( ) ,
1552
1557
flags : flags,
1553
- } ;
1558
+ } ) ;
1554
1559
1555
1560
let sty_ptr = & t. sty as * const sty ;
1556
1561
0 commit comments