@@ -52,29 +52,18 @@ impl UpvarId {
5252/// Information describing the capture of an upvar. This is computed
5353/// during `typeck`, specifically by `regionck`.
5454#[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
55- pub enum UpvarCapture < ' tcx > {
55+ pub enum UpvarCapture {
5656 /// Upvar is captured by value. This is always true when the
5757 /// closure is labeled `move`, but can also be true in other cases
5858 /// depending on inference.
5959 ByValue ,
6060
6161 /// Upvar is captured by reference.
62- ByRef ( UpvarBorrow < ' tcx > ) ,
63- }
64-
65- #[ derive( PartialEq , Clone , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
66- pub struct UpvarBorrow < ' tcx > {
67- /// The kind of borrow: by-ref upvars have access to shared
68- /// immutable borrows, which are not part of the normal language
69- /// syntax.
70- pub kind : BorrowKind ,
71-
72- /// Region of the resulting reference.
73- pub region : ty:: Region < ' tcx > ,
62+ ByRef ( BorrowKind ) ,
7463}
7564
7665pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
77- pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
66+ pub type UpvarCaptureMap = FxHashMap < UpvarId , UpvarCapture > ;
7867
7968/// Given the closure DefId this map provides a map of root variables to minimum
8069/// set of `CapturedPlace`s that need to be tracked to support all captures of that closure.
@@ -144,10 +133,13 @@ pub struct CapturedPlace<'tcx> {
144133 pub place : HirPlace < ' tcx > ,
145134
146135 /// `CaptureKind` and expression(s) that resulted in such capture of `place`.
147- pub info : CaptureInfo < ' tcx > ,
136+ pub info : CaptureInfo ,
148137
149138 /// Represents if `place` can be mutated or not.
150139 pub mutability : hir:: Mutability ,
140+
141+ /// Region of the resulting reference if the upvar is captured by ref.
142+ pub region : Option < ty:: Region < ' tcx > > ,
151143}
152144
153145impl < ' tcx > CapturedPlace < ' tcx > {
@@ -281,7 +273,7 @@ pub fn is_ancestor_or_same_capture(
281273/// for a particular capture as well as identifying the part of the source code
282274/// that triggered this capture to occur.
283275#[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
284- pub struct CaptureInfo < ' tcx > {
276+ pub struct CaptureInfo {
285277 /// Expr Id pointing to use that resulted in selecting the current capture kind
286278 ///
287279 /// Eg:
@@ -319,7 +311,7 @@ pub struct CaptureInfo<'tcx> {
319311 pub path_expr_id : Option < hir:: HirId > ,
320312
321313 /// Capture mode that was selected
322- pub capture_kind : UpvarCapture < ' tcx > ,
314+ pub capture_kind : UpvarCapture ,
323315}
324316
325317pub fn place_to_string_for_capture < ' tcx > ( tcx : TyCtxt < ' tcx > , place : & HirPlace < ' tcx > ) -> String {
0 commit comments