@@ -52,7 +52,7 @@ use crate::util::nodemap::{FxHashMap, FxHashSet};
52
52
use arena:: SyncDroplessArena ;
53
53
use errors:: DiagnosticBuilder ;
54
54
use rustc_data_structures:: profiling:: SelfProfilerRef ;
55
- use rustc_data_structures:: sharded:: ShardedHashMap ;
55
+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
56
56
use rustc_data_structures:: stable_hasher:: {
57
57
hash_stable_hashmap, HashStable , StableHasher , StableVec ,
58
58
} ;
@@ -1557,11 +1557,11 @@ pub trait Lift<'tcx>: fmt::Debug {
1557
1557
}
1558
1558
1559
1559
macro_rules! nop_lift {
1560
- ( $ty: ty => $lifted: ty) => {
1560
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1561
1561
impl <' a, ' tcx> Lift <' tcx> for $ty {
1562
1562
type Lifted = $lifted;
1563
1563
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 ) ) {
1565
1565
Some ( unsafe { mem:: transmute( * self ) } )
1566
1566
} else {
1567
1567
None
@@ -1572,14 +1572,14 @@ macro_rules! nop_lift {
1572
1572
}
1573
1573
1574
1574
macro_rules! nop_list_lift {
1575
- ( $ty: ty => $lifted: ty) => {
1575
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1576
1576
impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
1577
1577
type Lifted = & ' tcx List <$lifted>;
1578
1578
fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1579
1579
if self . is_empty( ) {
1580
1580
return Some ( List :: empty( ) ) ;
1581
1581
}
1582
- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1582
+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
1583
1583
Some ( unsafe { mem:: transmute( * self ) } )
1584
1584
} else {
1585
1585
None
@@ -1589,21 +1589,21 @@ macro_rules! nop_list_lift {
1589
1589
} ;
1590
1590
}
1591
1591
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>}
1596
1596
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 }
1604
1604
1605
1605
// 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>}
1607
1607
1608
1608
pub mod tls {
1609
1609
use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1927,6 +1927,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
1927
1927
}
1928
1928
impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
1929
1929
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
+ }
1930
1935
// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
1931
1936
impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
1932
1937
fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
0 commit comments