@@ -20,18 +20,37 @@ pub struct BorrowSet<'tcx> {
20
20
/// by the `Location` of the assignment statement in which it
21
21
/// appears on the right hand side. Thus the location is the map
22
22
/// key, and its position in the map corresponds to `BorrowIndex`.
23
- pub location_map : FxIndexMap < Location , BorrowData < ' tcx > > ,
23
+ pub ( crate ) location_map : FxIndexMap < Location , BorrowData < ' tcx > > ,
24
24
25
25
/// Locations which activate borrows.
26
26
/// NOTE: a given location may activate more than one borrow in the future
27
27
/// when more general two-phase borrow support is introduced, but for now we
28
28
/// only need to store one borrow index.
29
- pub activation_map : FxIndexMap < Location , Vec < BorrowIndex > > ,
29
+ pub ( crate ) activation_map : FxIndexMap < Location , Vec < BorrowIndex > > ,
30
30
31
31
/// Map from local to all the borrows on that local.
32
- pub local_map : FxIndexMap < mir:: Local , FxIndexSet < BorrowIndex > > ,
32
+ pub ( crate ) local_map : FxIndexMap < mir:: Local , FxIndexSet < BorrowIndex > > ,
33
33
34
- pub locals_state_at_exit : LocalsStateAtExit ,
34
+ pub ( crate ) locals_state_at_exit : LocalsStateAtExit ,
35
+ }
36
+
37
+ // These methods are public to support borrowck consumers.
38
+ impl < ' tcx > BorrowSet < ' tcx > {
39
+ pub fn location_map ( & self ) -> & FxIndexMap < Location , BorrowData < ' tcx > > {
40
+ & self . location_map
41
+ }
42
+
43
+ pub fn activation_map ( & self ) -> & FxIndexMap < Location , Vec < BorrowIndex > > {
44
+ & self . activation_map
45
+ }
46
+
47
+ pub fn local_map ( & self ) -> & FxIndexMap < mir:: Local , FxIndexSet < BorrowIndex > > {
48
+ & self . local_map
49
+ }
50
+
51
+ pub fn locals_state_at_exit ( & self ) -> & LocalsStateAtExit {
52
+ & self . locals_state_at_exit
53
+ }
35
54
}
36
55
37
56
impl < ' tcx > Index < BorrowIndex > for BorrowSet < ' tcx > {
@@ -55,17 +74,44 @@ pub enum TwoPhaseActivation {
55
74
pub struct BorrowData < ' tcx > {
56
75
/// Location where the borrow reservation starts.
57
76
/// In many cases, this will be equal to the activation location but not always.
58
- pub reserve_location : Location ,
77
+ pub ( crate ) reserve_location : Location ,
59
78
/// Location where the borrow is activated.
60
- pub activation_location : TwoPhaseActivation ,
79
+ pub ( crate ) activation_location : TwoPhaseActivation ,
61
80
/// What kind of borrow this is
62
- pub kind : mir:: BorrowKind ,
81
+ pub ( crate ) kind : mir:: BorrowKind ,
63
82
/// The region for which this borrow is live
64
- pub region : RegionVid ,
83
+ pub ( crate ) region : RegionVid ,
65
84
/// Place from which we are borrowing
66
- pub borrowed_place : mir:: Place < ' tcx > ,
85
+ pub ( crate ) borrowed_place : mir:: Place < ' tcx > ,
67
86
/// Place to which the borrow was stored
68
- pub assigned_place : mir:: Place < ' tcx > ,
87
+ pub ( crate ) assigned_place : mir:: Place < ' tcx > ,
88
+ }
89
+
90
+ // These methods are public to support borrowck consumers.
91
+ impl < ' tcx > BorrowData < ' tcx > {
92
+ pub fn reserve_location ( & self ) -> Location {
93
+ self . reserve_location
94
+ }
95
+
96
+ pub fn activation_location ( & self ) -> TwoPhaseActivation {
97
+ self . activation_location
98
+ }
99
+
100
+ pub fn kind ( & self ) -> mir:: BorrowKind {
101
+ self . kind
102
+ }
103
+
104
+ pub fn region ( & self ) -> RegionVid {
105
+ self . region
106
+ }
107
+
108
+ pub fn borrowed_place ( & self ) -> mir:: Place < ' tcx > {
109
+ self . borrowed_place
110
+ }
111
+
112
+ pub fn assigned_place ( & self ) -> mir:: Place < ' tcx > {
113
+ self . assigned_place
114
+ }
69
115
}
70
116
71
117
impl < ' tcx > fmt:: Display for BorrowData < ' tcx > {
0 commit comments