@@ -32,7 +32,7 @@ use ty::{self, TraitRef, Ty, TypeAndMut};
32
32
use ty:: { TyS , TypeVariants , Slice } ;
33
33
use ty:: { AdtKind , AdtDef , ClosureSubsts , Region } ;
34
34
use hir:: FreevarMap ;
35
- use ty:: { BareFnTy , InferTy , ParamTy , ProjectionTy , ExistentialPredicate } ;
35
+ use ty:: { PolyFnSig , InferTy , ParamTy , ProjectionTy , ExistentialPredicate } ;
36
36
use ty:: { TyVar , TyVid , IntVar , IntVid , FloatVar , FloatVid } ;
37
37
use ty:: TypeVariants :: * ;
38
38
use ty:: layout:: { Layout , TargetDataLayout } ;
@@ -53,6 +53,7 @@ use std::ops::Deref;
53
53
use std:: rc:: Rc ;
54
54
use std:: iter;
55
55
use std:: cmp:: Ordering ;
56
+ use syntax:: abi;
56
57
use syntax:: ast:: { self , Name , NodeId } ;
57
58
use syntax:: attr;
58
59
use syntax:: symbol:: { Symbol , keywords} ;
@@ -94,7 +95,6 @@ pub struct CtxtInterners<'tcx> {
94
95
type_ : RefCell < FxHashSet < Interned < ' tcx , TyS < ' tcx > > > > ,
95
96
type_list : RefCell < FxHashSet < Interned < ' tcx , Slice < Ty < ' tcx > > > > > ,
96
97
substs : RefCell < FxHashSet < Interned < ' tcx , Substs < ' tcx > > > > ,
97
- bare_fn : RefCell < FxHashSet < Interned < ' tcx , BareFnTy < ' tcx > > > > ,
98
98
region : RefCell < FxHashSet < Interned < ' tcx , Region > > > ,
99
99
existential_predicates : RefCell < FxHashSet < Interned < ' tcx , Slice < ExistentialPredicate < ' tcx > > > > > ,
100
100
}
@@ -106,7 +106,6 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
106
106
type_ : RefCell :: new ( FxHashSet ( ) ) ,
107
107
type_list : RefCell :: new ( FxHashSet ( ) ) ,
108
108
substs : RefCell :: new ( FxHashSet ( ) ) ,
109
- bare_fn : RefCell :: new ( FxHashSet ( ) ) ,
110
109
region : RefCell :: new ( FxHashSet ( ) ) ,
111
110
existential_predicates : RefCell :: new ( FxHashSet ( ) ) ,
112
111
}
@@ -219,7 +218,7 @@ pub struct TypeckTables<'tcx> {
219
218
pub upvar_capture_map : ty:: UpvarCaptureMap < ' tcx > ,
220
219
221
220
/// Records the type of each closure.
222
- pub closure_tys : NodeMap < ty:: ClosureTy < ' tcx > > ,
221
+ pub closure_tys : NodeMap < ty:: PolyFnSig < ' tcx > > ,
223
222
224
223
/// Records the kind of each closure.
225
224
pub closure_kinds : NodeMap < ty:: ClosureKind > ,
@@ -859,23 +858,6 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice<ExistentialPredicate<'a>> {
859
858
}
860
859
}
861
860
862
- impl < ' a , ' tcx > Lift < ' tcx > for & ' a BareFnTy < ' a > {
863
- type Lifted = & ' tcx BareFnTy < ' tcx > ;
864
- fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > )
865
- -> Option < & ' tcx BareFnTy < ' tcx > > {
866
- if tcx. interners . arena . in_arena ( * self as * const _ ) {
867
- return Some ( unsafe { mem:: transmute ( * self ) } ) ;
868
- }
869
- // Also try in the global tcx if we're not that.
870
- if !tcx. is_global ( ) {
871
- self . lift_to_tcx ( tcx. global_tcx ( ) )
872
- } else {
873
- None
874
- }
875
- }
876
- }
877
-
878
-
879
861
pub mod tls {
880
862
use super :: { CtxtInterners , GlobalCtxt , TyCtxt } ;
881
863
@@ -1028,7 +1010,6 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
1028
1010
TyDynamic , TyClosure , TyTuple , TyParam , TyInfer , TyProjection , TyAnon ) ;
1029
1011
1030
1012
println ! ( "Substs interner: #{}" , self . interners. substs. borrow( ) . len( ) ) ;
1031
- println ! ( "BareFnTy interner: #{}" , self . interners. bare_fn. borrow( ) . len( ) ) ;
1032
1013
println ! ( "Region interner: #{}" , self . interners. region. borrow( ) . len( ) ) ;
1033
1014
println ! ( "Stability interner: #{}" , self . stability_interner. borrow( ) . len( ) ) ;
1034
1015
println ! ( "Layout interner: #{}" , self . layout_interner. borrow( ) . len( ) ) ;
@@ -1087,12 +1068,6 @@ impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, Substs<'tcx>> {
1087
1068
}
1088
1069
}
1089
1070
1090
- impl < ' tcx : ' lcx , ' lcx > Borrow < BareFnTy < ' lcx > > for Interned < ' tcx , BareFnTy < ' tcx > > {
1091
- fn borrow < ' a > ( & ' a self ) -> & ' a BareFnTy < ' lcx > {
1092
- self . 0
1093
- }
1094
- }
1095
-
1096
1071
impl < ' tcx > Borrow < Region > for Interned < ' tcx , Region > {
1097
1072
fn borrow < ' a > ( & ' a self ) -> & ' a Region {
1098
1073
self . 0
@@ -1181,9 +1156,6 @@ fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
1181
1156
}
1182
1157
1183
1158
direct_interners ! ( ' tcx,
1184
- bare_fn: mk_bare_fn( |fty: & BareFnTy | {
1185
- keep_local( & fty. sig)
1186
- } ) -> BareFnTy <' tcx>,
1187
1159
region: mk_region( |r| {
1188
1160
match r {
1189
1161
& ty:: ReVar ( _) | & ty:: ReSkolemized ( ..) => true ,
@@ -1209,12 +1181,11 @@ slice_interners!(
1209
1181
1210
1182
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
1211
1183
/// Create an unsafe fn ty based on a safe fn ty.
1212
- pub fn safe_to_unsafe_fn_ty ( self , bare_fn : & BareFnTy < ' tcx > ) -> Ty < ' tcx > {
1213
- assert_eq ! ( bare_fn . unsafety, hir:: Unsafety :: Normal ) ;
1214
- self . mk_fn_ptr ( self . mk_bare_fn ( ty:: BareFnTy {
1184
+ pub fn safe_to_unsafe_fn_ty ( self , sig : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1185
+ assert_eq ! ( sig . unsafety( ) , hir:: Unsafety :: Normal ) ;
1186
+ self . mk_fn_ptr ( sig . map_bound ( |sig| ty:: FnSig {
1215
1187
unsafety : hir:: Unsafety :: Unsafe ,
1216
- abi : bare_fn. abi ,
1217
- sig : bare_fn. sig . clone ( )
1188
+ ..sig
1218
1189
} ) )
1219
1190
}
1220
1191
@@ -1341,11 +1312,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1341
1312
1342
1313
pub fn mk_fn_def ( self , def_id : DefId ,
1343
1314
substs : & ' tcx Substs < ' tcx > ,
1344
- fty : & ' tcx BareFnTy < ' tcx > ) -> Ty < ' tcx > {
1315
+ fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1345
1316
self . mk_ty ( TyFnDef ( def_id, substs, fty) )
1346
1317
}
1347
1318
1348
- pub fn mk_fn_ptr ( self , fty : & ' tcx BareFnTy < ' tcx > ) -> Ty < ' tcx > {
1319
+ pub fn mk_fn_ptr ( self , fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1349
1320
self . mk_ty ( TyFnPtr ( fty) )
1350
1321
}
1351
1322
@@ -1439,14 +1410,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1439
1410
}
1440
1411
}
1441
1412
1442
- pub fn mk_fn_sig < I > ( self , inputs : I , output : I :: Item , variadic : bool )
1413
+ pub fn mk_fn_sig < I > ( self ,
1414
+ inputs : I ,
1415
+ output : I :: Item ,
1416
+ variadic : bool ,
1417
+ unsafety : hir:: Unsafety ,
1418
+ abi : abi:: Abi )
1443
1419
-> <I :: Item as InternIteratorElement < Ty < ' tcx > , ty:: FnSig < ' tcx > > >:: Output
1444
1420
where I : Iterator ,
1445
1421
I :: Item : InternIteratorElement < Ty < ' tcx > , ty:: FnSig < ' tcx > >
1446
1422
{
1447
1423
inputs. chain ( iter:: once ( output) ) . intern_with ( |xs| ty:: FnSig {
1448
1424
inputs_and_output : self . intern_type_list ( xs) ,
1449
- variadic : variadic
1425
+ variadic, unsafety , abi
1450
1426
} )
1451
1427
}
1452
1428
0 commit comments