@@ -52,29 +52,18 @@ impl UpvarId {
52
52
/// Information describing the capture of an upvar. This is computed
53
53
/// during `typeck`, specifically by `regionck`.
54
54
#[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
55
- pub enum UpvarCapture < ' tcx > {
55
+ pub enum UpvarCapture {
56
56
/// Upvar is captured by value. This is always true when the
57
57
/// closure is labeled `move`, but can also be true in other cases
58
58
/// depending on inference.
59
59
ByValue ,
60
60
61
61
/// 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 ) ,
74
63
}
75
64
76
65
pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
77
- pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
66
+ pub type UpvarCaptureMap = FxHashMap < UpvarId , UpvarCapture > ;
78
67
79
68
/// Given the closure DefId this map provides a map of root variables to minimum
80
69
/// set of `CapturedPlace`s that need to be tracked to support all captures of that closure.
@@ -144,10 +133,13 @@ pub struct CapturedPlace<'tcx> {
144
133
pub place : HirPlace < ' tcx > ,
145
134
146
135
/// `CaptureKind` and expression(s) that resulted in such capture of `place`.
147
- pub info : CaptureInfo < ' tcx > ,
136
+ pub info : CaptureInfo ,
148
137
149
138
/// Represents if `place` can be mutated or not.
150
139
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 > > ,
151
143
}
152
144
153
145
impl < ' tcx > CapturedPlace < ' tcx > {
@@ -281,7 +273,7 @@ pub fn is_ancestor_or_same_capture(
281
273
/// for a particular capture as well as identifying the part of the source code
282
274
/// that triggered this capture to occur.
283
275
#[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
284
- pub struct CaptureInfo < ' tcx > {
276
+ pub struct CaptureInfo {
285
277
/// Expr Id pointing to use that resulted in selecting the current capture kind
286
278
///
287
279
/// Eg:
@@ -319,7 +311,7 @@ pub struct CaptureInfo<'tcx> {
319
311
pub path_expr_id : Option < hir:: HirId > ,
320
312
321
313
/// Capture mode that was selected
322
- pub capture_kind : UpvarCapture < ' tcx > ,
314
+ pub capture_kind : UpvarCapture ,
323
315
}
324
316
325
317
pub fn place_to_string_for_capture < ' tcx > ( tcx : TyCtxt < ' tcx > , place : & HirPlace < ' tcx > ) -> String {
0 commit comments