@@ -456,6 +456,11 @@ impl ty::EarlyBoundRegion {
456456 }
457457}
458458
459+ /// A statement that can be proven by a trait solver. This includes things that may
460+ /// show up in where clauses, such as trait predicates and projection predicates,
461+ /// and also things that are emitted as part of type checking such as `ObjectSafe`
462+ /// predicate which is emitted when a type is coerced to a trait object.
463+ ///
459464/// Use this rather than `PredicateKind`, whenever possible.
460465#[ derive( Clone , Copy , PartialEq , Eq , Hash , HashStable ) ]
461466#[ rustc_pass_by_value]
@@ -561,7 +566,9 @@ impl rustc_errors::IntoDiagnosticArg for Predicate<'_> {
561566 }
562567}
563568
564- /// TODO: doc
569+ /// A subset of predicates which can be assumed by the trait solver. They show up in
570+ /// an item's where clauses, hence the name `Clause`, and may either be user-written
571+ /// (such as traits) or may be inserted during lowering.
565572#[ derive( Clone , Copy , PartialEq , Eq , Hash , HashStable ) ]
566573#[ rustc_pass_by_value]
567574pub struct Clause < ' tcx > ( Interned < ' tcx , WithCachedTypeInfo < ty:: Binder < ' tcx , PredicateKind < ' tcx > > > > ) ;
@@ -1409,13 +1416,16 @@ impl<'tcx> Predicate<'tcx> {
14091416 }
14101417 }
14111418
1419+ /// Matches a `PredicateKind::Clause` and turns it into a `Clause`, otherwise returns `None`.
14121420 pub fn as_clause ( self ) -> Option < Clause < ' tcx > > {
14131421 match self . kind ( ) . skip_binder ( ) {
14141422 PredicateKind :: Clause ( ..) => Some ( self . expect_clause ( ) ) ,
14151423 _ => None ,
14161424 }
14171425 }
14181426
1427+ /// Turns a predicate into a clause without checking that it is a `PredicateKind::Clause`
1428+ /// first. This will ICE when methods are called on `Clause`.
14191429 pub fn expect_clause ( self ) -> Clause < ' tcx > {
14201430 match self . kind ( ) . skip_binder ( ) {
14211431 PredicateKind :: Clause ( ..) => Clause ( self . 0 ) ,
0 commit comments