@@ -52,35 +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
- ///
60
- /// If the upvar was inferred to be captured by value (e.g. `move`
61
- /// was not used), then the `Span` points to a usage that
62
- /// required it. There may be more than one such usage
63
- /// (e.g. `|| { a; a; }`), in which case we pick an
64
- /// arbitrary one.
65
- ByValue ( Option < Span > ) ,
59
+ ByValue ,
66
60
67
61
/// Upvar is captured by reference.
68
- ByRef ( UpvarBorrow < ' tcx > ) ,
69
- }
70
-
71
- #[ derive( PartialEq , Clone , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
72
- pub struct UpvarBorrow < ' tcx > {
73
- /// The kind of borrow: by-ref upvars have access to shared
74
- /// immutable borrows, which are not part of the normal language
75
- /// syntax.
76
- pub kind : BorrowKind ,
77
-
78
- /// Region of the resulting reference.
79
- pub region : ty:: Region < ' tcx > ,
62
+ ByRef ( BorrowKind ) ,
80
63
}
81
64
82
65
pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
83
- pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
66
+ pub type UpvarCaptureMap = FxHashMap < UpvarId , UpvarCapture > ;
84
67
85
68
/// Given the closure DefId this map provides a map of root variables to minimum
86
69
/// set of `CapturedPlace`s that need to be tracked to support all captures of that closure.
@@ -150,10 +133,13 @@ pub struct CapturedPlace<'tcx> {
150
133
pub place : HirPlace < ' tcx > ,
151
134
152
135
/// `CaptureKind` and expression(s) that resulted in such capture of `place`.
153
- pub info : CaptureInfo < ' tcx > ,
136
+ pub info : CaptureInfo ,
154
137
155
138
/// Represents if `place` can be mutated or not.
156
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 > > ,
157
143
}
158
144
159
145
impl < ' tcx > CapturedPlace < ' tcx > {
@@ -287,7 +273,7 @@ pub fn is_ancestor_or_same_capture(
287
273
/// for a particular capture as well as identifying the part of the source code
288
274
/// that triggered this capture to occur.
289
275
#[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
290
- pub struct CaptureInfo < ' tcx > {
276
+ pub struct CaptureInfo {
291
277
/// Expr Id pointing to use that resulted in selecting the current capture kind
292
278
///
293
279
/// Eg:
@@ -325,7 +311,7 @@ pub struct CaptureInfo<'tcx> {
325
311
pub path_expr_id : Option < hir:: HirId > ,
326
312
327
313
/// Capture mode that was selected
328
- pub capture_kind : UpvarCapture < ' tcx > ,
314
+ pub capture_kind : UpvarCapture ,
329
315
}
330
316
331
317
pub fn place_to_string_for_capture < ' tcx > ( tcx : TyCtxt < ' tcx > , place : & HirPlace < ' tcx > ) -> String {
0 commit comments