@@ -394,23 +394,26 @@ pub enum ClosureOutlivesSubject<'tcx> {
394394
395395/// Represents a `ty::Ty` for use in [`ClosureOutlivesSubject`].
396396///
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.
400403#[ derive( Copy , Clone , Debug , TyEncodable , TyDecodable , HashStable ) ]
401404pub struct ClosureOutlivesSubjectTy < ' tcx > {
402405 inner : Ty < ' tcx > ,
403406}
404407
405408impl < ' 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 {
409412 let inner = tcx. fold_regions ( ty, |r, depth| match r. kind ( ) {
410413 ty:: ReVar ( vid) => {
411414 let br = ty:: BoundRegion {
412415 var : ty:: BoundVar :: new ( vid. index ( ) ) ,
413- kind : ty:: BrAnon ( 0u32 , None ) ,
416+ kind : ty:: BrAnon ( vid . as_u32 ( ) , None ) ,
414417 } ;
415418 tcx. mk_re_late_bound ( depth, br)
416419 }
0 commit comments