@@ -54,8 +54,8 @@ use hir;
54
54
pub struct CtxtArenas < ' tcx > {
55
55
// internings
56
56
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 > > ,
59
59
bare_fn : TypedArena < BareFnTy < ' tcx > > ,
60
60
region : TypedArena < Region > ,
61
61
stability : TypedArena < attr:: Stability > ,
@@ -1117,6 +1117,7 @@ impl<'tcx> Borrow<Region> for Interned<'tcx, Region> {
1117
1117
1118
1118
macro_rules! intern_method {
1119
1119
( $lt_tcx: tt, $name: ident: $method: ident( $alloc: ty,
1120
+ $alloc_method: ident,
1120
1121
$alloc_to_key: expr,
1121
1122
$alloc_to_ret: expr,
1122
1123
$needs_infer: expr) -> $ty: ty) => {
@@ -1142,7 +1143,8 @@ macro_rules! intern_method {
1142
1143
let v = unsafe {
1143
1144
mem:: transmute( v)
1144
1145
} ;
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) ) ;
1146
1148
self . global_interners. $name. borrow_mut( ) . insert( Interned ( i) ) ;
1147
1149
return i;
1148
1150
}
@@ -1156,7 +1158,7 @@ macro_rules! intern_method {
1156
1158
}
1157
1159
}
1158
1160
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) ) ;
1160
1162
self . interners. $name. borrow_mut( ) . insert( Interned ( i) ) ;
1161
1163
i
1162
1164
}
@@ -1180,7 +1182,7 @@ macro_rules! direct_interners {
1180
1182
}
1181
1183
}
1182
1184
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) ; ) +
1184
1186
}
1185
1187
}
1186
1188
@@ -1200,16 +1202,18 @@ direct_interners!('tcx,
1200
1202
} ) -> Region
1201
1203
) ;
1202
1204
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
+ }
1208
1213
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 )
1213
1217
) ;
1214
1218
1215
1219
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -1314,12 +1318,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1314
1318
self . mk_ty ( TySlice ( ty) )
1315
1319
}
1316
1320
1317
- pub fn mk_tup ( self , ts : Vec < Ty < ' tcx > > ) -> Ty < ' tcx > {
1321
+ pub fn mk_tup ( self , ts : & [ Ty < ' tcx > ] ) -> Ty < ' tcx > {
1318
1322
self . mk_ty ( TyTuple ( self . mk_type_list ( ts) ) )
1319
1323
}
1320
1324
1321
1325
pub fn mk_nil ( self ) -> Ty < ' tcx > {
1322
- self . mk_tup ( Vec :: new ( ) )
1326
+ self . mk_tup ( & [ ] )
1323
1327
}
1324
1328
1325
1329
pub fn mk_diverging_default ( self ) -> Ty < ' tcx > {
@@ -1361,7 +1365,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1361
1365
pub fn mk_closure ( self ,
1362
1366
closure_id : DefId ,
1363
1367
substs : & ' tcx Substs < ' tcx > ,
1364
- tys : Vec < Ty < ' tcx > > )
1368
+ tys : & [ Ty < ' tcx > ] )
1365
1369
-> Ty < ' tcx > {
1366
1370
self . mk_closure_from_closure_substs ( closure_id, ClosureSubsts {
1367
1371
func_substs : substs,
0 commit comments