@@ -5,6 +5,7 @@ use rustc_hir::def_id::DefId;
55use rustc_macros:: { HashStable , Lift , TyDecodable , TyEncodable , TypeFoldable , TypeVisitable } ;
66use rustc_type_ir:: ClauseKind as IrClauseKind ;
77use rustc_type_ir:: PredicateKind as IrPredicateKind ;
8+ use rustc_type_ir:: TraitPredicate as IrTraitPredicate ;
89use rustc_type_ir:: TraitRef as IrTraitRef ;
910use std:: cmp:: Ordering ;
1011
@@ -15,6 +16,7 @@ use crate::ty::{
1516} ;
1617
1718pub type TraitRef < ' tcx > = IrTraitRef < TyCtxt < ' tcx > > ;
19+ pub type TraitPredicate < ' tcx > = IrTraitPredicate < TyCtxt < ' tcx > > ;
1820pub type ClauseKind < ' tcx > = IrClauseKind < TyCtxt < ' tcx > > ;
1921pub type PredicateKind < ' tcx > = IrPredicateKind < TyCtxt < ' tcx > > ;
2022
@@ -578,37 +580,8 @@ impl<'tcx> Clause<'tcx> {
578580 }
579581}
580582
581- #[ derive( Clone , Copy , PartialEq , Eq , Hash , TyEncodable , TyDecodable ) ]
582- #[ derive( HashStable , TypeFoldable , TypeVisitable , Lift ) ]
583- pub struct TraitPredicate < ' tcx > {
584- pub trait_ref : TraitRef < ' tcx > ,
585-
586- /// If polarity is Positive: we are proving that the trait is implemented.
587- ///
588- /// If polarity is Negative: we are proving that a negative impl of this trait
589- /// exists. (Note that coherence also checks whether negative impls of supertraits
590- /// exist via a series of predicates.)
591- ///
592- /// If polarity is Reserved: that's a bug.
593- pub polarity : PredicatePolarity ,
594- }
595-
596583pub type PolyTraitPredicate < ' tcx > = ty:: Binder < ' tcx , TraitPredicate < ' tcx > > ;
597584
598- impl < ' tcx > TraitPredicate < ' tcx > {
599- pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> Self {
600- Self { trait_ref : self . trait_ref . with_self_ty ( tcx, self_ty) , ..self }
601- }
602-
603- pub fn def_id ( self ) -> DefId {
604- self . trait_ref . def_id
605- }
606-
607- pub fn self_ty ( self ) -> Ty < ' tcx > {
608- self . trait_ref . self_ty ( )
609- }
610- }
611-
612585impl < ' tcx > PolyTraitPredicate < ' tcx > {
613586 pub fn def_id ( self ) -> DefId {
614587 // Ok to skip binder since trait `DefId` does not care about regions.
0 commit comments