@@ -53,7 +53,7 @@ use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet};
53
53
use arena:: SyncDroplessArena ;
54
54
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
55
55
use rustc_data_structures:: profiling:: SelfProfilerRef ;
56
- use rustc_data_structures:: sharded:: ShardedHashMap ;
56
+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
57
57
use rustc_data_structures:: stable_hasher:: {
58
58
hash_stable_hashmap, HashStable , StableHasher , StableVec ,
59
59
} ;
@@ -1560,11 +1560,11 @@ pub trait Lift<'tcx>: fmt::Debug {
1560
1560
}
1561
1561
1562
1562
macro_rules! nop_lift {
1563
- ( $ty: ty => $lifted: ty) => {
1563
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1564
1564
impl <' a, ' tcx> Lift <' tcx> for $ty {
1565
1565
type Lifted = $lifted;
1566
1566
fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1567
- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1567
+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
1568
1568
Some ( unsafe { mem:: transmute( * self ) } )
1569
1569
} else {
1570
1570
None
@@ -1575,14 +1575,14 @@ macro_rules! nop_lift {
1575
1575
}
1576
1576
1577
1577
macro_rules! nop_list_lift {
1578
- ( $ty: ty => $lifted: ty) => {
1578
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1579
1579
impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
1580
1580
type Lifted = & ' tcx List <$lifted>;
1581
1581
fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1582
1582
if self . is_empty( ) {
1583
1583
return Some ( List :: empty( ) ) ;
1584
1584
}
1585
- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1585
+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
1586
1586
Some ( unsafe { mem:: transmute( * self ) } )
1587
1587
} else {
1588
1588
None
@@ -1592,21 +1592,21 @@ macro_rules! nop_list_lift {
1592
1592
} ;
1593
1593
}
1594
1594
1595
- nop_lift ! { Ty <' a> => Ty <' tcx>}
1596
- nop_lift ! { Region <' a> => Region <' tcx>}
1597
- nop_lift ! { Goal <' a> => Goal <' tcx>}
1598
- nop_lift ! { & ' a Const <' a> => & ' tcx Const <' tcx>}
1595
+ nop_lift ! { type_ ; Ty <' a> => Ty <' tcx>}
1596
+ nop_lift ! { region ; Region <' a> => Region <' tcx>}
1597
+ nop_lift ! { goal ; Goal <' a> => Goal <' tcx>}
1598
+ nop_lift ! { const_ ; & ' a Const <' a> => & ' tcx Const <' tcx>}
1599
1599
1600
- nop_list_lift ! { Goal <' a> => Goal <' tcx>}
1601
- nop_list_lift ! { Clause <' a> => Clause <' tcx>}
1602
- nop_list_lift ! { Ty <' a> => Ty <' tcx>}
1603
- nop_list_lift ! { ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1604
- nop_list_lift ! { Predicate <' a> => Predicate <' tcx>}
1605
- nop_list_lift ! { CanonicalVarInfo => CanonicalVarInfo }
1606
- nop_list_lift ! { ProjectionKind => ProjectionKind }
1600
+ nop_list_lift ! { goal_list ; Goal <' a> => Goal <' tcx>}
1601
+ nop_list_lift ! { clauses ; Clause <' a> => Clause <' tcx>}
1602
+ nop_list_lift ! { type_list ; Ty <' a> => Ty <' tcx>}
1603
+ nop_list_lift ! { existential_predicates ; ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1604
+ nop_list_lift ! { predicates ; Predicate <' a> => Predicate <' tcx>}
1605
+ nop_list_lift ! { canonical_var_infos ; CanonicalVarInfo => CanonicalVarInfo }
1606
+ nop_list_lift ! { projs ; ProjectionKind => ProjectionKind }
1607
1607
1608
1608
// This is the impl for `&'a InternalSubsts<'a>`.
1609
- nop_list_lift ! { GenericArg <' a> => GenericArg <' tcx>}
1609
+ nop_list_lift ! { substs ; GenericArg <' a> => GenericArg <' tcx>}
1610
1610
1611
1611
pub mod tls {
1612
1612
use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1930,6 +1930,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
1930
1930
}
1931
1931
impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
1932
1932
1933
+ impl < ' tcx , T : ' tcx + ?Sized > IntoPointer for Interned < ' tcx , T > {
1934
+ fn into_pointer ( & self ) -> * const ( ) {
1935
+ self . 0 as * const _ as * const ( )
1936
+ }
1937
+ }
1933
1938
// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
1934
1939
impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
1935
1940
fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
0 commit comments