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>>;
56
56
pub type TraitObligation < ' tcx > = Obligation < ' tcx , ty:: PolyTraitPredicate < ' tcx > > ;
57
57
58
58
impl 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`.
59
62
pub fn flip_polarity ( & self , tcx : TyCtxt < ' tcx > ) -> Option < PredicateObligation < ' tcx > > {
60
63
Some ( PredicateObligation {
61
64
cause : self . cause . clone ( ) ,
Original file line number Diff line number Diff line change @@ -190,6 +190,7 @@ pub enum ImplPolarity {
190
190
}
191
191
192
192
impl ImplPolarity {
193
+ /// Flips polarity by turning `Positive` into `Negative` and `Negative` into `Positive`.
193
194
pub fn flip ( & self ) -> Option < ImplPolarity > {
194
195
match self {
195
196
ImplPolarity :: Positive => Some ( ImplPolarity :: Negative ) ,
@@ -492,6 +493,9 @@ impl<'tcx> Predicate<'tcx> {
492
493
self . inner . kind
493
494
}
494
495
496
+ /// Flips the polarity of a Predicate.
497
+ ///
498
+ /// Given `T: Trait` predicate it returns `T: !Trait` and given `T: !Trait` returns `T: Trait`.
495
499
pub fn flip_polarity ( & self , tcx : TyCtxt < ' tcx > ) -> Option < Predicate < ' tcx > > {
496
500
let kind = self
497
501
. inner
You can’t perform that action at this time.
0 commit comments