@@ -32,7 +32,7 @@ use ty::{self, TraitRef, Ty, TypeAndMut};
3232use ty:: { TyS , TypeVariants , Slice } ;
3333use ty:: { AdtKind , AdtDef , ClosureSubsts , Region } ;
3434use hir:: FreevarMap ;
35- use ty:: { BareFnTy , InferTy , ParamTy , ProjectionTy , ExistentialPredicate } ;
35+ use ty:: { PolyFnSig , InferTy , ParamTy , ProjectionTy , ExistentialPredicate } ;
3636use ty:: { TyVar , TyVid , IntVar , IntVid , FloatVar , FloatVid } ;
3737use ty:: TypeVariants :: * ;
3838use ty:: layout:: { Layout , TargetDataLayout } ;
@@ -53,6 +53,7 @@ use std::ops::Deref;
5353use std:: rc:: Rc ;
5454use std:: iter;
5555use std:: cmp:: Ordering ;
56+ use syntax:: abi;
5657use syntax:: ast:: { self , Name , NodeId } ;
5758use syntax:: attr;
5859use syntax:: symbol:: { Symbol , keywords} ;
@@ -94,7 +95,6 @@ pub struct CtxtInterners<'tcx> {
9495 type_ : RefCell < FxHashSet < Interned < ' tcx , TyS < ' tcx > > > > ,
9596 type_list : RefCell < FxHashSet < Interned < ' tcx , Slice < Ty < ' tcx > > > > > ,
9697 substs : RefCell < FxHashSet < Interned < ' tcx , Substs < ' tcx > > > > ,
97- bare_fn : RefCell < FxHashSet < Interned < ' tcx , BareFnTy < ' tcx > > > > ,
9898 region : RefCell < FxHashSet < Interned < ' tcx , Region > > > ,
9999 existential_predicates : RefCell < FxHashSet < Interned < ' tcx , Slice < ExistentialPredicate < ' tcx > > > > > ,
100100}
@@ -106,7 +106,6 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
106106 type_ : RefCell :: new ( FxHashSet ( ) ) ,
107107 type_list : RefCell :: new ( FxHashSet ( ) ) ,
108108 substs : RefCell :: new ( FxHashSet ( ) ) ,
109- bare_fn : RefCell :: new ( FxHashSet ( ) ) ,
110109 region : RefCell :: new ( FxHashSet ( ) ) ,
111110 existential_predicates : RefCell :: new ( FxHashSet ( ) ) ,
112111 }
@@ -219,7 +218,7 @@ pub struct TypeckTables<'tcx> {
219218 pub upvar_capture_map : ty:: UpvarCaptureMap < ' tcx > ,
220219
221220 /// Records the type of each closure.
222- pub closure_tys : NodeMap < ty:: ClosureTy < ' tcx > > ,
221+ pub closure_tys : NodeMap < ty:: PolyFnSig < ' tcx > > ,
223222
224223 /// Records the kind of each closure.
225224 pub closure_kinds : NodeMap < ty:: ClosureKind > ,
@@ -859,23 +858,6 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice<ExistentialPredicate<'a>> {
859858 }
860859}
861860
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-
879861pub mod tls {
880862 use super :: { CtxtInterners , GlobalCtxt , TyCtxt } ;
881863
@@ -1028,7 +1010,6 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
10281010 TyDynamic , TyClosure , TyTuple , TyParam , TyInfer , TyProjection , TyAnon ) ;
10291011
10301012 println ! ( "Substs interner: #{}" , self . interners. substs. borrow( ) . len( ) ) ;
1031- println ! ( "BareFnTy interner: #{}" , self . interners. bare_fn. borrow( ) . len( ) ) ;
10321013 println ! ( "Region interner: #{}" , self . interners. region. borrow( ) . len( ) ) ;
10331014 println ! ( "Stability interner: #{}" , self . stability_interner. borrow( ) . len( ) ) ;
10341015 println ! ( "Layout interner: #{}" , self . layout_interner. borrow( ) . len( ) ) ;
@@ -1087,12 +1068,6 @@ impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, Substs<'tcx>> {
10871068 }
10881069}
10891070
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-
10961071impl < ' tcx > Borrow < Region > for Interned < ' tcx , Region > {
10971072 fn borrow < ' a > ( & ' a self ) -> & ' a Region {
10981073 self . 0
@@ -1181,9 +1156,6 @@ fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
11811156}
11821157
11831158direct_interners ! ( ' tcx,
1184- bare_fn: mk_bare_fn( |fty: & BareFnTy | {
1185- keep_local( & fty. sig)
1186- } ) -> BareFnTy <' tcx>,
11871159 region: mk_region( |r| {
11881160 match r {
11891161 & ty:: ReVar ( _) | & ty:: ReSkolemized ( ..) => true ,
@@ -1209,12 +1181,11 @@ slice_interners!(
12091181
12101182impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
12111183 /// 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 {
12151187 unsafety : hir:: Unsafety :: Unsafe ,
1216- abi : bare_fn. abi ,
1217- sig : bare_fn. sig . clone ( )
1188+ ..sig
12181189 } ) )
12191190 }
12201191
@@ -1341,11 +1312,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13411312
13421313 pub fn mk_fn_def ( self , def_id : DefId ,
13431314 substs : & ' tcx Substs < ' tcx > ,
1344- fty : & ' tcx BareFnTy < ' tcx > ) -> Ty < ' tcx > {
1315+ fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
13451316 self . mk_ty ( TyFnDef ( def_id, substs, fty) )
13461317 }
13471318
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 > {
13491320 self . mk_ty ( TyFnPtr ( fty) )
13501321 }
13511322
@@ -1439,14 +1410,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14391410 }
14401411 }
14411412
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 )
14431419 -> <I :: Item as InternIteratorElement < Ty < ' tcx > , ty:: FnSig < ' tcx > > >:: Output
14441420 where I : Iterator ,
14451421 I :: Item : InternIteratorElement < Ty < ' tcx > , ty:: FnSig < ' tcx > >
14461422 {
14471423 inputs. chain ( iter:: once ( output) ) . intern_with ( |xs| ty:: FnSig {
14481424 inputs_and_output : self . intern_type_list ( xs) ,
1449- variadic : variadic
1425+ variadic, unsafety , abi
14501426 } )
14511427 }
14521428
0 commit comments