@@ -190,44 +190,7 @@ 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
- /// 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
- ///
197
- /// ```rust
198
- /// fn foo<'a, 'b, T: SomeTrait<'a>>
199
- /// where
200
- /// <T as SomeTrait<'a>>::Item: 'b
201
- /// ```
202
- ///
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.
208
- ///
209
- /// More abstractly, this function takes a `Binder<VerifyIfEq>`. The binder
210
- /// represents an existential binder -- i.e., if you have something like
211
- ///
212
- /// ```rust
213
- /// where for<'a> <T as SomeTrait<'a>::Item: 'a
214
- /// ```
215
- ///
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
- /// ```
193
+ /// See [`VerifyIfEq`] docs
231
194
IfEq ( ty:: Binder < ' tcx , VerifyIfEq < ' tcx > > ) ,
232
195
233
196
/// Given a region `R`, expands to the function:
@@ -271,40 +234,44 @@ pub enum VerifyBound<'tcx> {
271
234
AllBounds ( Vec < VerifyBound < ' tcx > > ) ,
272
235
}
273
236
274
- /// Given a kind K and a bound B, expands to a function like the
275
- /// following, where `G` is the generic for which this verify
276
- /// bound was created :
237
+ /// This is a "conditional bound" that checks the result of inference
238
+ /// and supplies a bound if it ended up being relevant. It's used in situations
239
+ /// like this :
277
240
///
278
- /// ```ignore (pseudo-rust)
279
- /// fn(min) -> bool {
280
- /// if G == K {
281
- /// B(min)
282
- /// } else {
283
- /// false
284
- /// }
285
- /// }
241
+ /// ```rust
242
+ /// fn foo<'a, 'b, T: SomeTrait<'a>>
243
+ /// where
244
+ /// <T as SomeTrait<'a>>::Item: 'b
286
245
/// ```
287
246
///
288
- /// In other words, if the generic `G` that we are checking is
289
- /// equal to `K`, then check the associated verify bound
290
- /// (otherwise, false).
291
- ///
292
- /// This is used when we have something in the environment that
293
- /// may or may not be relevant, depending on the region inference
294
- /// results. For example, we may have `where <T as
295
- /// Trait<'a>>::Item: 'b` in our where-clauses. If we are
296
- /// generating the verify-bound for `<T as Trait<'0>>::Item`, then
297
- /// this where-clause is only relevant if `'0` winds up inferred
298
- /// to `'a`.
247
+ /// If we have an obligation like `<T as SomeTrait<'?x>>::Item: 'c`, then
248
+ /// we don't know yet whether it suffices to show that `'b: 'c`. If `'?x` winds
249
+ /// up being equal to `'a`, then the where-clauses on function applies, and
250
+ /// in that case we can show `'b: 'c`. But if `'?x` winds up being something
251
+ /// else, the bound isn't relevant.
299
252
///
300
- /// So we would compile to a verify-bound like
253
+ /// In the [`VerifyBound`], this struct is enclosed in `Binder to account
254
+ /// for cases like
301
255
///
302
- /// ```ignore (illustrative)
303
- /// IfEq(< T as Trait <'a>> ::Item, AnyRegion('a))
256
+ /// ```rust
257
+ /// where for<'a> < T as SomeTrait <'a>::Item: 'a
304
258
/// ```
305
259
///
306
- /// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
307
- /// (after inference), and `'a: min`, then `G: min`.
260
+ /// The idea is that we have to find some instantiation of `'a` that can
261
+ /// make `<T as SomeTrait<'a>>::Item` equal to the final value of `G`,
262
+ /// the generic we are checking.
263
+ ///
264
+ /// ```ignore (pseudo-rust)
265
+ /// fn(min) -> bool {
266
+ /// exists<'a> {
267
+ /// if G == K {
268
+ /// B(min)
269
+ /// } else {
270
+ /// false
271
+ /// }
272
+ /// }
273
+ /// }
274
+ /// ```
308
275
#[ derive( Debug , Copy , Clone , TypeFoldable ) ]
309
276
pub struct VerifyIfEq < ' tcx > {
310
277
/// Type which must match the generic `G`
0 commit comments