@@ -817,10 +817,8 @@ pub trait Lift<'tcx> {
817
817
impl < ' a , ' tcx > Lift < ' tcx > for Ty < ' a > {
818
818
type Lifted = Ty < ' tcx > ;
819
819
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 ) } ) ;
824
822
}
825
823
// Also try in the global tcx if we're not that.
826
824
if !tcx. is_global ( ) {
@@ -837,10 +835,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> {
837
835
if self . len ( ) == 0 {
838
836
return Some ( Slice :: empty ( ) ) ;
839
837
}
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 ) } ) ;
844
840
}
845
841
// Also try in the global tcx if we're not that.
846
842
if !tcx. is_global ( ) {
@@ -854,10 +850,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> {
854
850
impl < ' a , ' tcx > Lift < ' tcx > for & ' a Region {
855
851
type Lifted = & ' tcx Region ;
856
852
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 ) } ) ;
861
855
}
862
856
// Also try in the global tcx if we're not that.
863
857
if !tcx. is_global ( ) {
@@ -875,10 +869,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice<Ty<'a>> {
875
869
if self . len ( ) == 0 {
876
870
return Some ( Slice :: empty ( ) ) ;
877
871
}
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 ) } ) ;
882
874
}
883
875
// Also try in the global tcx if we're not that.
884
876
if !tcx. is_global ( ) {
@@ -896,10 +888,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice<ExistentialPredicate<'a>> {
896
888
if self . is_empty ( ) {
897
889
return Some ( Slice :: empty ( ) ) ;
898
890
}
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 ) } ) ;
903
893
}
904
894
// Also try in the global tcx if we're not that.
905
895
if !tcx. is_global ( ) {
@@ -914,10 +904,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a BareFnTy<'a> {
914
904
type Lifted = & ' tcx BareFnTy < ' tcx > ;
915
905
fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > )
916
906
-> 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 ) } ) ;
921
909
}
922
910
// Also try in the global tcx if we're not that.
923
911
if !tcx. is_global ( ) {
@@ -1201,7 +1189,7 @@ macro_rules! intern_method {
1201
1189
}
1202
1190
}
1203
1191
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) ) ;
1205
1193
self . interners. $name. borrow_mut( ) . insert( Interned ( i) ) ;
1206
1194
i
1207
1195
}
0 commit comments