This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
5656pub type TraitObligation < ' tcx > = Obligation < ' tcx , ty:: PolyTraitPredicate < ' tcx > > ;
5757
5858impl PredicateObligation < ' tcx > {
59+ /// Flips the polarity of the inner predicate.
60+ ///
61+ /// Given `T: Trait` predicate it returns `T: !Trait` and given `T: !Trait` returns `T: Trait`.
5962 pub fn flip_polarity ( & self , tcx : TyCtxt < ' tcx > ) -> Option < PredicateObligation < ' tcx > > {
6063 Some ( PredicateObligation {
6164 cause : self . cause . clone ( ) ,
Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ pub enum ImplPolarity {
190190}
191191
192192impl ImplPolarity {
193+ /// Flips polarity by turning `Positive` into `Negative` and `Negative` into `Positive`.
193194 pub fn flip ( & self ) -> Option < ImplPolarity > {
194195 match self {
195196 ImplPolarity :: Positive => Some ( ImplPolarity :: Negative ) ,
@@ -492,6 +493,9 @@ impl<'tcx> Predicate<'tcx> {
492493 self . inner . kind
493494 }
494495
496+ /// Flips the polarity of a Predicate.
497+ ///
498+ /// Given `T: Trait` predicate it returns `T: !Trait` and given `T: !Trait` returns `T: Trait`.
495499 pub fn flip_polarity ( & self , tcx : TyCtxt < ' tcx > ) -> Option < Predicate < ' tcx > > {
496500 let kind = self
497501 . inner
You can’t perform that action at this time.
0 commit comments