@@ -394,23 +394,26 @@ pub enum ClosureOutlivesSubject<'tcx> {
394
394
395
395
/// Represents a `ty::Ty` for use in [`ClosureOutlivesSubject`].
396
396
///
397
- /// This indirection is necessary because the type may include `ReVar` regions,
398
- /// which is what we use internally within NLL code,
399
- /// and we can't use `ReVar`s in a query response.
397
+ /// This abstraction is necessary because the type may include `ReVar` regions,
398
+ /// which is what we use internally within NLL code, and they can't be used in
399
+ /// a query response.
400
+ ///
401
+ /// DO NOT implement `TypeVisitable` or `TypeFoldable` traits, because this
402
+ /// type is not recognized as a binder for late-bound region.
400
403
#[ derive( Copy , Clone , Debug , TyEncodable , TyDecodable , HashStable ) ]
401
404
pub struct ClosureOutlivesSubjectTy < ' tcx > {
402
405
inner : Ty < ' tcx > ,
403
406
}
404
407
405
408
impl < ' tcx > ClosureOutlivesSubjectTy < ' tcx > {
406
- // All regions of `ty` must be of kind `ReVar`
407
- // and must point to an early-bound region in the closure's signature .
408
- pub fn new ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> Self {
409
+ /// All regions of `ty` must be of kind `ReVar` and must represent
410
+ /// universal regions *external* to the closure.
411
+ pub fn bind ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> Self {
409
412
let inner = tcx. fold_regions ( ty, |r, depth| match r. kind ( ) {
410
413
ty:: ReVar ( vid) => {
411
414
let br = ty:: BoundRegion {
412
415
var : ty:: BoundVar :: new ( vid. index ( ) ) ,
413
- kind : ty:: BrAnon ( 0u32 , None ) ,
416
+ kind : ty:: BrAnon ( vid . as_u32 ( ) , None ) ,
414
417
} ;
415
418
tcx. mk_re_late_bound ( depth, br)
416
419
}
0 commit comments