@@ -20,18 +20,37 @@ pub struct BorrowSet<'tcx> {
2020 /// by the `Location` of the assignment statement in which it
2121 /// appears on the right hand side. Thus the location is the map
2222 /// 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 > > ,
2424
2525 /// Locations which activate borrows.
2626 /// NOTE: a given location may activate more than one borrow in the future
2727 /// when more general two-phase borrow support is introduced, but for now we
2828 /// only need to store one borrow index.
29- pub activation_map : FxIndexMap < Location , Vec < BorrowIndex > > ,
29+ pub ( crate ) activation_map : FxIndexMap < Location , Vec < BorrowIndex > > ,
3030
3131 /// 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 > > ,
3333
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+ }
3554}
3655
3756impl < ' tcx > Index < BorrowIndex > for BorrowSet < ' tcx > {
@@ -55,17 +74,44 @@ pub enum TwoPhaseActivation {
5574pub struct BorrowData < ' tcx > {
5675 /// Location where the borrow reservation starts.
5776 /// 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 ,
5978 /// Location where the borrow is activated.
60- pub activation_location : TwoPhaseActivation ,
79+ pub ( crate ) activation_location : TwoPhaseActivation ,
6180 /// What kind of borrow this is
62- pub kind : mir:: BorrowKind ,
81+ pub ( crate ) kind : mir:: BorrowKind ,
6382 /// The region for which this borrow is live
64- pub region : RegionVid ,
83+ pub ( crate ) region : RegionVid ,
6584 /// Place from which we are borrowing
66- pub borrowed_place : mir:: Place < ' tcx > ,
85+ pub ( crate ) borrowed_place : mir:: Place < ' tcx > ,
6786 /// 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+ }
69115}
70116
71117impl < ' tcx > fmt:: Display for BorrowData < ' tcx > {
0 commit comments