@@ -29,10 +29,9 @@ use crate::ty::{self, DefIdTree, Ty, TypeAndMut};
2929use crate :: ty:: { AdtDef , AdtKind , Const , Region } ;
3030use crate :: ty:: { BindingMode , BoundVar } ;
3131use crate :: ty:: { ConstVid , FloatVar , FloatVid , IntVar , IntVid , TyVar , TyVid } ;
32- use crate :: ty:: {
33- ExistentialPredicate , InferTy , ParamTy , PolyFnSig , Predicate , PredicateKind , ProjectionTy ,
34- } ;
32+ use crate :: ty:: { ExistentialPredicate , Predicate , PredicateKind } ;
3533use crate :: ty:: { InferConst , ParamConst } ;
34+ use crate :: ty:: { InferTy , ParamTy , PolyFnSig , ProjectionTy } ;
3635use crate :: ty:: { List , TyKind , TyS } ;
3736use rustc_ast:: ast;
3837use rustc_ast:: expand:: allocator:: AllocatorKind ;
@@ -91,6 +90,7 @@ pub struct CtxtInterners<'tcx> {
9190 canonical_var_infos : InternedSet < ' tcx , List < CanonicalVarInfo > > ,
9291 region : InternedSet < ' tcx , RegionKind > ,
9392 existential_predicates : InternedSet < ' tcx , List < ExistentialPredicate < ' tcx > > > ,
93+ predicate_kind : InternedSet < ' tcx , PredicateKind < ' tcx > > ,
9494 predicates : InternedSet < ' tcx , List < Predicate < ' tcx > > > ,
9595 projs : InternedSet < ' tcx , List < ProjectionKind > > ,
9696 place_elems : InternedSet < ' tcx , List < PlaceElem < ' tcx > > > ,
@@ -109,6 +109,7 @@ impl<'tcx> CtxtInterners<'tcx> {
109109 region : Default :: default ( ) ,
110110 existential_predicates : Default :: default ( ) ,
111111 canonical_var_infos : Default :: default ( ) ,
112+ predicate_kind : Default :: default ( ) ,
112113 predicates : Default :: default ( ) ,
113114 projs : Default :: default ( ) ,
114115 place_elems : Default :: default ( ) ,
@@ -1579,6 +1580,7 @@ macro_rules! nop_list_lift {
15791580nop_lift ! { type_; Ty <' a> => Ty <' tcx>}
15801581nop_lift ! { region; Region <' a> => Region <' tcx>}
15811582nop_lift ! { const_; & ' a Const <' a> => & ' tcx Const <' tcx>}
1583+ nop_lift ! { predicate_kind; & ' a PredicateKind <' a> => & ' tcx PredicateKind <' tcx>}
15821584
15831585nop_list_lift ! { type_list; Ty <' a> => Ty <' tcx>}
15841586nop_list_lift ! { existential_predicates; ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
@@ -2017,8 +2019,14 @@ impl<'tcx> Borrow<[traits::ChalkEnvironmentClause<'tcx>]>
20172019 }
20182020}
20192021
2022+ impl < ' tcx > Borrow < PredicateKind < ' tcx > > for Interned < ' tcx , PredicateKind < ' tcx > > {
2023+ fn borrow < ' a > ( & ' a self ) -> & ' a PredicateKind < ' tcx > {
2024+ & self . 0
2025+ }
2026+ }
2027+
20202028macro_rules! direct_interners {
2021- ( $( $name: ident: $method: ident( $ty: ty) ) , +) => {
2029+ ( $( $name: ident: $method: ident( $ty: ty) , ) +) => {
20222030 $( impl <' tcx> PartialEq for Interned <' tcx, $ty> {
20232031 fn eq( & self , other: & Self ) -> bool {
20242032 self . 0 == other. 0
@@ -2043,7 +2051,11 @@ macro_rules! direct_interners {
20432051 }
20442052}
20452053
2046- direct_interners ! ( region: mk_region( RegionKind ) , const_: mk_const( Const <' tcx>) ) ;
2054+ direct_interners ! (
2055+ region: mk_region( RegionKind ) ,
2056+ const_: mk_const( Const <' tcx>) ,
2057+ predicate_kind: intern_predicate_kind( PredicateKind <' tcx>) ,
2058+ ) ;
20472059
20482060macro_rules! slice_interners {
20492061 ( $( $field: ident: $method: ident( $ty: ty) ) ,+) => (
@@ -2107,6 +2119,7 @@ impl<'tcx> TyCtxt<'tcx> {
21072119
21082120 #[ inline]
21092121 pub fn mk_predicate ( & self , kind : PredicateKind < ' tcx > ) -> Predicate < ' tcx > {
2122+ let kind = self . intern_predicate_kind ( kind) ;
21102123 Predicate { kind }
21112124 }
21122125
0 commit comments