@@ -817,10 +817,8 @@ pub trait Lift<'tcx> {
817817impl < ' a , ' tcx > Lift < ' tcx > for Ty < ' a > {
818818 type Lifted = Ty < ' tcx > ;
819819 fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Ty < ' tcx > > {
820- if let Some ( & Interned ( ty) ) = tcx. interners . type_ . borrow ( ) . get ( & self . sty ) {
821- if * self as * const _ == ty as * const _ {
822- return Some ( ty) ;
823- }
820+ if tcx. interners . arena . in_arena ( * self as * const _ ) {
821+ return Some ( unsafe { mem:: transmute ( * self ) } ) ;
824822 }
825823 // Also try in the global tcx if we're not that.
826824 if !tcx. is_global ( ) {
@@ -837,10 +835,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> {
837835 if self . len ( ) == 0 {
838836 return Some ( Slice :: empty ( ) ) ;
839837 }
840- if let Some ( & Interned ( substs) ) = tcx. interners . substs . borrow ( ) . get ( & self [ ..] ) {
841- if * self as * const _ == substs as * const _ {
842- return Some ( substs) ;
843- }
838+ if tcx. interners . arena . in_arena ( & self [ ..] as * const _ ) {
839+ return Some ( unsafe { mem:: transmute ( * self ) } ) ;
844840 }
845841 // Also try in the global tcx if we're not that.
846842 if !tcx. is_global ( ) {
@@ -854,10 +850,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> {
854850impl < ' a , ' tcx > Lift < ' tcx > for & ' a Region {
855851 type Lifted = & ' tcx Region ;
856852 fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < & ' tcx Region > {
857- if let Some ( & Interned ( region) ) = tcx. interners . region . borrow ( ) . get ( * self ) {
858- if * self as * const _ == region as * const _ {
859- return Some ( region) ;
860- }
853+ if tcx. interners . arena . in_arena ( * self as * const _ ) {
854+ return Some ( unsafe { mem:: transmute ( * self ) } ) ;
861855 }
862856 // Also try in the global tcx if we're not that.
863857 if !tcx. is_global ( ) {
@@ -875,10 +869,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice<Ty<'a>> {
875869 if self . len ( ) == 0 {
876870 return Some ( Slice :: empty ( ) ) ;
877871 }
878- if let Some ( & Interned ( list) ) = tcx. interners . type_list . borrow ( ) . get ( & self [ ..] ) {
879- if * self as * const _ == list as * const _ {
880- return Some ( list) ;
881- }
872+ if tcx. interners . arena . in_arena ( * self as * const _ ) {
873+ return Some ( unsafe { mem:: transmute ( * self ) } ) ;
882874 }
883875 // Also try in the global tcx if we're not that.
884876 if !tcx. is_global ( ) {
@@ -896,10 +888,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice<ExistentialPredicate<'a>> {
896888 if self . is_empty ( ) {
897889 return Some ( Slice :: empty ( ) ) ;
898890 }
899- if let Some ( & Interned ( eps) ) = tcx. interners . existential_predicates . borrow ( ) . get ( & self [ ..] ) {
900- if * self as * const _ == eps as * const _ {
901- return Some ( eps) ;
902- }
891+ if tcx. interners . arena . in_arena ( * self as * const _ ) {
892+ return Some ( unsafe { mem:: transmute ( * self ) } ) ;
903893 }
904894 // Also try in the global tcx if we're not that.
905895 if !tcx. is_global ( ) {
@@ -914,10 +904,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a BareFnTy<'a> {
914904 type Lifted = & ' tcx BareFnTy < ' tcx > ;
915905 fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > )
916906 -> Option < & ' tcx BareFnTy < ' tcx > > {
917- if let Some ( & Interned ( fty) ) = tcx. interners . bare_fn . borrow ( ) . get ( * self ) {
918- if * self as * const _ == fty as * const _ {
919- return Some ( fty) ;
920- }
907+ if tcx. interners . arena . in_arena ( * self as * const _ ) {
908+ return Some ( unsafe { mem:: transmute ( * self ) } ) ;
921909 }
922910 // Also try in the global tcx if we're not that.
923911 if !tcx. is_global ( ) {
@@ -1201,7 +1189,7 @@ macro_rules! intern_method {
12011189 }
12021190 }
12031191
1204- let i = ( $alloc_to_ret) ( self . global_interners . arena. $alloc_method( v) ) ;
1192+ let i = ( $alloc_to_ret) ( self . interners . arena. $alloc_method( v) ) ;
12051193 self . interners. $name. borrow_mut( ) . insert( Interned ( i) ) ;
12061194 i
12071195 }
0 commit comments