@@ -190,42 +190,44 @@ pub enum GenericKind<'tcx> {
190
190
/// This is described with an `AnyRegion('a, 'b)` node.
191
191
#[ derive( Debug , Clone ) ]
192
192
pub enum VerifyBound < ' tcx > {
193
- /// Given a kind K and a bound B, expands to a function like the
194
- /// following, where `G` is the generic for which this verify
195
- /// bound was created :
193
+ /// This is a "conditional bound" that checks the result of inference
194
+ /// and supplies a bound if it ended up being relevant. It's used in situations
195
+ /// like this :
196
196
///
197
- /// ```ignore (pseudo-rust)
198
- /// fn(min) -> bool {
199
- /// if G == K {
200
- /// B(min)
201
- /// } else {
202
- /// false
203
- /// }
204
- /// }
197
+ /// ```rust
198
+ /// fn foo<'a, 'b, T: SomeTrait<'a>>
199
+ /// where
200
+ /// <T as SomeTrait<'a>>::Item: 'b
205
201
/// ```
206
202
///
207
- /// In other words, if the generic `G` that we are checking is
208
- /// equal to `K`, then check the associated verify bound
209
- /// (otherwise, false).
210
- ///
211
- /// This is used when we have something in the environment that
212
- /// may or may not be relevant, depending on the region inference
213
- /// results. For example, we may have `where <T as
214
- /// Trait<'a>>::Item: 'b` in our where-clauses. If we are
215
- /// generating the verify-bound for `<T as Trait<'0>>::Item`, then
216
- /// this where-clause is only relevant if `'0` winds up inferred
217
- /// to `'a`.
203
+ /// If we have an obligation like `<T as SomeTrait<'?x>>::Item: 'c`, then
204
+ /// we don't know yet whether it suffices to show that `'b: 'c`. If `'?x` winds
205
+ /// up being equal to `'a`, then the where-clauses on function applies, and
206
+ /// in that case we can show `'b: 'c`. But if `'?x` winds up being something
207
+ /// else, the bound isn't relevant.
218
208
///
219
- /// So we would compile to a verify-bound like
209
+ /// More abstractly, this function takes a `Binder<VerifyIfEq>`. The binder
210
+ /// represents an existential binder -- i.e., if you have something like
220
211
///
221
- /// ```ignore (illustrative)
222
- /// IfEq(< T as Trait <'a>> ::Item, AnyRegion('a))
212
+ /// ```rust
213
+ /// where for<'a> < T as SomeTrait <'a>::Item: 'a
223
214
/// ```
224
215
///
225
- /// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
226
- /// (after inference), and `'a: min`, then `G: min`.
227
- IfEq ( Ty < ' tcx > , Region < ' tcx > ) ,
228
-
216
+ /// then the `for<'a>` corresponds to the binder. The idea is that we have
217
+ /// to find some instantiation of `'a` that can make `<T as SomeTrait<'a>>::Item`
218
+ /// equal to the final value of `G`, the generic we are checking.
219
+ ///
220
+ /// ```ignore (pseudo-rust)
221
+ /// fn(min) -> bool {
222
+ /// exists<'a> {
223
+ /// if G == K {
224
+ /// B(min)
225
+ /// } else {
226
+ /// false
227
+ /// }
228
+ /// }
229
+ /// }
230
+ /// ```
229
231
IfEqBound ( ty:: Binder < ' tcx , VerifyIfEq < ' tcx > > ) ,
230
232
231
233
/// Given a region `R`, expands to the function:
@@ -805,7 +807,6 @@ impl<'tcx> GenericKind<'tcx> {
805
807
impl < ' tcx > VerifyBound < ' tcx > {
806
808
pub fn must_hold ( & self ) -> bool {
807
809
match self {
808
- VerifyBound :: IfEq ( ..) => false ,
809
810
VerifyBound :: IfEqBound ( ..) => false ,
810
811
VerifyBound :: OutlivedBy ( re) => re. is_static ( ) ,
811
812
VerifyBound :: IsEmpty => false ,
@@ -816,7 +817,6 @@ impl<'tcx> VerifyBound<'tcx> {
816
817
817
818
pub fn cannot_hold ( & self ) -> bool {
818
819
match self {
819
- VerifyBound :: IfEq ( _, _) => false ,
820
820
VerifyBound :: IfEqBound ( ..) => false ,
821
821
VerifyBound :: IsEmpty => false ,
822
822
VerifyBound :: OutlivedBy ( _) => false ,
0 commit comments