@@ -50,6 +50,7 @@ use std::mem;
5050use std:: ops;
5151use std:: rc:: Rc ;
5252use std:: collections:: { HashMap , HashSet } ;
53+ use arena:: TypedArena ;
5354use syntax:: abi;
5455use syntax:: ast:: { CrateNum , DefId , FnStyle , Ident , ItemTrait , LOCAL_CRATE } ;
5556use syntax:: ast:: { MutImmutable , MutMutable , Name , NamedField , NodeId } ;
@@ -418,10 +419,13 @@ pub struct TransmuteRestriction {
418419/// The data structure to keep track of all the information that typechecker
419420/// generates so that so that it can be reused and doesn't have to be redone
420421/// later on.
421- pub struct ctxt {
422+ pub struct ctxt < ' tcx > {
423+ /// The arena that types are allocated from.
424+ type_arena : & ' tcx TypedArena < t_box_ > ,
425+
422426 /// Specifically use a speedy hash algorithm for this hash map, it's used
423427 /// quite often.
424- pub interner : RefCell < FnvHashMap < intern_key , Box < t_box_ > > > ,
428+ interner : RefCell < FnvHashMap < intern_key , & ' tcx t_box_ > > ,
425429 pub next_id : Cell < uint > ,
426430 pub sess : Session ,
427431 pub def_map : resolve:: DefMap ,
@@ -1373,21 +1377,22 @@ impl UnboxedClosureKind {
13731377 }
13741378}
13751379
1376- pub fn mk_ctxt ( s : Session ,
1377- dm : resolve :: DefMap ,
1378- named_region_map : resolve_lifetime :: NamedRegionMap ,
1379- map : ast_map :: Map ,
1380- freevars : freevars :: freevar_map ,
1381- capture_modes : freevars:: CaptureModeMap ,
1382- region_maps : middle :: region :: RegionMaps ,
1383- lang_items : middle:: lang_items :: LanguageItems ,
1384- stability : stability :: Index )
1385- -> ctxt {
1380+ pub fn mk_ctxt < ' tcx > ( s : Session ,
1381+ type_arena : & ' tcx TypedArena < t_box_ > ,
1382+ dm : resolve :: DefMap ,
1383+ named_region_map : resolve_lifetime :: NamedRegionMap ,
1384+ map : ast_map :: Map ,
1385+ freevars : freevars:: freevar_map ,
1386+ capture_modes : freevars :: CaptureModeMap ,
1387+ region_maps : middle:: region :: RegionMaps ,
1388+ lang_items : middle :: lang_items :: LanguageItems ,
1389+ stability : stability :: Index ) -> ctxt < ' tcx > {
13861390 ctxt {
1391+ type_arena : type_arena,
1392+ interner : RefCell :: new ( FnvHashMap :: new ( ) ) ,
13871393 named_region_map : named_region_map,
13881394 item_variance_map : RefCell :: new ( DefIdMap :: new ( ) ) ,
13891395 variance_computed : Cell :: new ( false ) ,
1390- interner : RefCell :: new ( FnvHashMap :: new ( ) ) ,
13911396 next_id : Cell :: new ( primitives:: LAST_PRIMITIVE_ID ) ,
13921397 sess : s,
13931398 def_map : dm,
@@ -1554,11 +1559,11 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
15541559 }
15551560 }
15561561
1557- let t = box t_box_ {
1562+ let t = cx . type_arena . alloc ( t_box_ {
15581563 sty : st,
15591564 id : cx. next_id . get ( ) ,
15601565 flags : flags,
1561- } ;
1566+ } ) ;
15621567
15631568 let sty_ptr = & t. sty as * const sty ;
15641569
0 commit comments