@@ -52,35 +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.
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 ,
6660
6761 /// 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 ) ,
8063}
8164
8265pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
83- pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
66+ pub type UpvarCaptureMap = FxHashMap < UpvarId , UpvarCapture > ;
8467
8568/// Given the closure DefId this map provides a map of root variables to minimum
8669/// set of `CapturedPlace`s that need to be tracked to support all captures of that closure.
@@ -150,10 +133,13 @@ pub struct CapturedPlace<'tcx> {
150133 pub place : HirPlace < ' tcx > ,
151134
152135 /// `CaptureKind` and expression(s) that resulted in such capture of `place`.
153- pub info : CaptureInfo < ' tcx > ,
136+ pub info : CaptureInfo ,
154137
155138 /// Represents if `place` can be mutated or not.
156139 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 > > ,
157143}
158144
159145impl < ' tcx > CapturedPlace < ' tcx > {
@@ -287,7 +273,7 @@ pub fn is_ancestor_or_same_capture(
287273/// for a particular capture as well as identifying the part of the source code
288274/// that triggered this capture to occur.
289275#[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
290- pub struct CaptureInfo < ' tcx > {
276+ pub struct CaptureInfo {
291277 /// Expr Id pointing to use that resulted in selecting the current capture kind
292278 ///
293279 /// Eg:
@@ -325,7 +311,7 @@ pub struct CaptureInfo<'tcx> {
325311 pub path_expr_id : Option < hir:: HirId > ,
326312
327313 /// Capture mode that was selected
328- pub capture_kind : UpvarCapture < ' tcx > ,
314+ pub capture_kind : UpvarCapture ,
329315}
330316
331317pub fn place_to_string_for_capture < ' tcx > ( tcx : TyCtxt < ' tcx > , place : & HirPlace < ' tcx > ) -> String {
0 commit comments