@@ -54,8 +54,8 @@ use hir;
5454pub struct CtxtArenas < ' tcx > {
5555 // internings
5656 type_ : TypedArena < TyS < ' tcx > > ,
57- type_list : TypedArena < Vec < Ty < ' tcx > > > ,
58- substs : TypedArena < Vec < Kind < ' tcx > > > ,
57+ type_list : TypedArena < Ty < ' tcx > > ,
58+ substs : TypedArena < Kind < ' tcx > > ,
5959 bare_fn : TypedArena < BareFnTy < ' tcx > > ,
6060 region : TypedArena < Region > ,
6161 stability : TypedArena < attr:: Stability > ,
@@ -1117,6 +1117,7 @@ impl<'tcx> Borrow<Region> for Interned<'tcx, Region> {
11171117
11181118macro_rules! intern_method {
11191119 ( $lt_tcx: tt, $name: ident: $method: ident( $alloc: ty,
1120+ $alloc_method: ident,
11201121 $alloc_to_key: expr,
11211122 $alloc_to_ret: expr,
11221123 $needs_infer: expr) -> $ty: ty) => {
@@ -1142,7 +1143,8 @@ macro_rules! intern_method {
11421143 let v = unsafe {
11431144 mem:: transmute( v)
11441145 } ;
1145- let i = ( $alloc_to_ret) ( self . global_interners. arenas. $name. alloc( v) ) ;
1146+ let i = ( $alloc_to_ret) ( self . global_interners. arenas. $name
1147+ . $alloc_method( v) ) ;
11461148 self . global_interners. $name. borrow_mut( ) . insert( Interned ( i) ) ;
11471149 return i;
11481150 }
@@ -1156,7 +1158,7 @@ macro_rules! intern_method {
11561158 }
11571159 }
11581160
1159- let i = ( $alloc_to_ret) ( self . interners. arenas. $name. alloc ( v) ) ;
1161+ let i = ( $alloc_to_ret) ( self . interners. arenas. $name. $alloc_method ( v) ) ;
11601162 self . interners. $name. borrow_mut( ) . insert( Interned ( i) ) ;
11611163 i
11621164 }
@@ -1180,7 +1182,7 @@ macro_rules! direct_interners {
11801182 }
11811183 }
11821184
1183- intern_method!( $lt_tcx, $name: $method( $ty, |x| x, |x| x, $needs_infer) -> $ty) ; ) +
1185+ intern_method!( $lt_tcx, $name: $method( $ty, alloc , |x| x, |x| x, $needs_infer) -> $ty) ; ) +
11841186 }
11851187}
11861188
@@ -1200,16 +1202,18 @@ direct_interners!('tcx,
12001202 } ) -> Region
12011203) ;
12021204
1203- intern_method ! ( ' tcx,
1204- type_list: mk_type_list( Vec <Ty <' tcx>>, Deref :: deref, |xs: & [ Ty ] | -> & Slice <Ty > {
1205- unsafe { mem:: transmute( xs) }
1206- } , keep_local) -> Slice <Ty <' tcx>>
1207- ) ;
1205+ macro_rules! slice_interners {
1206+ ( $( $field: ident: $method: ident( $ty: ident) ) ,+) => (
1207+ $( intern_method!( ' tcx, $field: $method( & [ $ty<' tcx>] , alloc_slice, Deref :: deref,
1208+ |xs: & [ $ty] | -> & Slice <$ty> {
1209+ unsafe { mem:: transmute( xs) }
1210+ } , |xs: & [ $ty] | xs. iter( ) . any( keep_local) ) -> Slice <$ty<' tcx>>) ; ) +
1211+ )
1212+ }
12081213
1209- intern_method ! ( ' tcx,
1210- substs: mk_substs( Vec <Kind <' tcx>>, Deref :: deref, |xs: & [ Kind ] | -> & Slice <Kind > {
1211- unsafe { mem:: transmute( xs) }
1212- } , keep_local) -> Slice <Kind <' tcx>>
1214+ slice_interners ! (
1215+ type_list: mk_type_list( Ty ) ,
1216+ substs: mk_substs( Kind )
12131217) ;
12141218
12151219impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -1314,12 +1318,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13141318 self . mk_ty ( TySlice ( ty) )
13151319 }
13161320
1317- pub fn mk_tup ( self , ts : Vec < Ty < ' tcx > > ) -> Ty < ' tcx > {
1321+ pub fn mk_tup ( self , ts : & [ Ty < ' tcx > ] ) -> Ty < ' tcx > {
13181322 self . mk_ty ( TyTuple ( self . mk_type_list ( ts) ) )
13191323 }
13201324
13211325 pub fn mk_nil ( self ) -> Ty < ' tcx > {
1322- self . mk_tup ( Vec :: new ( ) )
1326+ self . mk_tup ( & [ ] )
13231327 }
13241328
13251329 pub fn mk_diverging_default ( self ) -> Ty < ' tcx > {
@@ -1361,7 +1365,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13611365 pub fn mk_closure ( self ,
13621366 closure_id : DefId ,
13631367 substs : & ' tcx Substs < ' tcx > ,
1364- tys : Vec < Ty < ' tcx > > )
1368+ tys : & [ Ty < ' tcx > ] )
13651369 -> Ty < ' tcx > {
13661370 self . mk_closure_from_closure_substs ( closure_id, ClosureSubsts {
13671371 func_substs : substs,
0 commit comments