@@ -52,7 +52,7 @@ use crate::util::nodemap::{FxHashMap, FxHashSet};
5252use arena:: SyncDroplessArena ;
5353use errors:: DiagnosticBuilder ;
5454use rustc_data_structures:: profiling:: SelfProfilerRef ;
55- use rustc_data_structures:: sharded:: ShardedHashMap ;
55+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
5656use rustc_data_structures:: stable_hasher:: {
5757 hash_stable_hashmap, HashStable , StableHasher , StableVec ,
5858} ;
@@ -1557,11 +1557,11 @@ pub trait Lift<'tcx>: fmt::Debug {
15571557}
15581558
15591559macro_rules! nop_lift {
1560- ( $ty: ty => $lifted: ty) => {
1560+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
15611561 impl <' a, ' tcx> Lift <' tcx> for $ty {
15621562 type Lifted = $lifted;
15631563 fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1564- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1564+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
15651565 Some ( unsafe { mem:: transmute( * self ) } )
15661566 } else {
15671567 None
@@ -1572,14 +1572,14 @@ macro_rules! nop_lift {
15721572}
15731573
15741574macro_rules! nop_list_lift {
1575- ( $ty: ty => $lifted: ty) => {
1575+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
15761576 impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
15771577 type Lifted = & ' tcx List <$lifted>;
15781578 fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
15791579 if self . is_empty( ) {
15801580 return Some ( List :: empty( ) ) ;
15811581 }
1582- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1582+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
15831583 Some ( unsafe { mem:: transmute( * self ) } )
15841584 } else {
15851585 None
@@ -1589,21 +1589,21 @@ macro_rules! nop_list_lift {
15891589 } ;
15901590}
15911591
1592- nop_lift ! { Ty <' a> => Ty <' tcx>}
1593- nop_lift ! { Region <' a> => Region <' tcx>}
1594- nop_lift ! { Goal <' a> => Goal <' tcx>}
1595- nop_lift ! { & ' a Const <' a> => & ' tcx Const <' tcx>}
1592+ nop_lift ! { type_ ; Ty <' a> => Ty <' tcx>}
1593+ nop_lift ! { region ; Region <' a> => Region <' tcx>}
1594+ nop_lift ! { goal ; Goal <' a> => Goal <' tcx>}
1595+ nop_lift ! { const_ ; & ' a Const <' a> => & ' tcx Const <' tcx>}
15961596
1597- nop_list_lift ! { Goal <' a> => Goal <' tcx>}
1598- nop_list_lift ! { Clause <' a> => Clause <' tcx>}
1599- nop_list_lift ! { Ty <' a> => Ty <' tcx>}
1600- nop_list_lift ! { ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1601- nop_list_lift ! { Predicate <' a> => Predicate <' tcx>}
1602- nop_list_lift ! { CanonicalVarInfo => CanonicalVarInfo }
1603- nop_list_lift ! { ProjectionKind => ProjectionKind }
1597+ nop_list_lift ! { goal_list ; Goal <' a> => Goal <' tcx>}
1598+ nop_list_lift ! { clauses ; Clause <' a> => Clause <' tcx>}
1599+ nop_list_lift ! { type_list ; Ty <' a> => Ty <' tcx>}
1600+ nop_list_lift ! { existential_predicates ; ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1601+ nop_list_lift ! { predicates ; Predicate <' a> => Predicate <' tcx>}
1602+ nop_list_lift ! { canonical_var_infos ; CanonicalVarInfo => CanonicalVarInfo }
1603+ nop_list_lift ! { projs ; ProjectionKind => ProjectionKind }
16041604
16051605// This is the impl for `&'a InternalSubsts<'a>`.
1606- nop_list_lift ! { GenericArg <' a> => GenericArg <' tcx>}
1606+ nop_list_lift ! { substs ; GenericArg <' a> => GenericArg <' tcx>}
16071607
16081608pub mod tls {
16091609 use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1927,6 +1927,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
19271927}
19281928impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
19291929
1930+ unsafe impl < ' tcx , T : ' tcx + ?Sized > IntoPointer for Interned < ' tcx , T > {
1931+ fn into_pointer ( & self ) -> * const ( ) {
1932+ self . 0 as * const _ as * const ( )
1933+ }
1934+ }
19301935// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
19311936impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
19321937 fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
0 commit comments