From 78346489c66779d024c60af2d2f0f5d9d455f688 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 17 Mar 2022 11:10:19 -0300 Subject: [PATCH] Add comments on Polarity --- compiler/rustc_middle/src/ty/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e7cef9e198b6..83ab761aa55a 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -748,6 +748,13 @@ pub struct TraitPredicate<'tcx> { pub constness: BoundConstness, + /// If polarity is Positive: we are proving that the trait is implemented. + /// + /// If polarity is Negative: we are proving that a negative impl of this trait + /// exists. (Note that coherence also checks whether negative impls of supertraits + /// exist via a series of predicates.) + /// + /// If polarity is Reserved: that's a bug. pub polarity: ImplPolarity, }