@@ -115,16 +115,16 @@ impl Cache {
115
115
}
116
116
117
117
#[ derive( Clone , Debug , HashStable , RustcEncodable , RustcDecodable , TypeFoldable ) ]
118
- pub struct BodyCache < ' tcx > {
119
- cache : Cache ,
118
+ pub struct BodyAndCache < ' tcx > {
120
119
body : Body < ' tcx > ,
120
+ cache : Cache ,
121
121
}
122
122
123
- impl BodyCache < ' tcx > {
123
+ impl BodyAndCache < ' tcx > {
124
124
pub fn new ( body : Body < ' tcx > ) -> Self {
125
125
Self {
126
- cache : Cache :: new ( ) ,
127
126
body,
127
+ cache : Cache :: new ( ) ,
128
128
}
129
129
}
130
130
}
@@ -139,7 +139,7 @@ macro_rules! read_only {
139
139
} ;
140
140
}
141
141
142
- impl BodyCache < ' tcx > {
142
+ impl BodyAndCache < ' tcx > {
143
143
pub fn ensure_predecessors ( & mut self ) {
144
144
self . cache . ensure_predecessors ( & self . body ) ;
145
145
}
@@ -148,8 +148,8 @@ impl BodyCache<'tcx> {
148
148
self . cache . predecessors ( & self . body )
149
149
}
150
150
151
- pub fn unwrap_read_only ( & self ) -> ReadOnlyBodyCache < ' _ , ' tcx > {
152
- ReadOnlyBodyCache :: new ( & self . cache , & self . body )
151
+ pub fn unwrap_read_only ( & self ) -> ReadOnlyBodyAndCache < ' _ , ' tcx > {
152
+ ReadOnlyBodyAndCache :: new ( & self . body , & self . cache )
153
153
}
154
154
155
155
pub fn basic_blocks_mut ( & mut self ) -> & mut IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
@@ -163,48 +163,48 @@ impl BodyCache<'tcx> {
163
163
}
164
164
}
165
165
166
- impl < ' tcx > Index < BasicBlock > for BodyCache < ' tcx > {
166
+ impl < ' tcx > Index < BasicBlock > for BodyAndCache < ' tcx > {
167
167
type Output = BasicBlockData < ' tcx > ;
168
168
169
169
fn index ( & self , index : BasicBlock ) -> & BasicBlockData < ' tcx > {
170
170
& self . body [ index]
171
171
}
172
172
}
173
173
174
- impl < ' tcx > IndexMut < BasicBlock > for BodyCache < ' tcx > {
174
+ impl < ' tcx > IndexMut < BasicBlock > for BodyAndCache < ' tcx > {
175
175
fn index_mut ( & mut self , index : BasicBlock ) -> & mut Self :: Output {
176
176
& mut self . basic_blocks_mut ( ) [ index]
177
177
}
178
178
}
179
179
180
- impl < ' tcx > Deref for BodyCache < ' tcx > {
180
+ impl < ' tcx > Deref for BodyAndCache < ' tcx > {
181
181
type Target = Body < ' tcx > ;
182
182
183
183
fn deref ( & self ) -> & Self :: Target {
184
184
& self . body
185
185
}
186
186
}
187
187
188
- impl < ' tcx > DerefMut for BodyCache < ' tcx > {
188
+ impl < ' tcx > DerefMut for BodyAndCache < ' tcx > {
189
189
fn deref_mut ( & mut self ) -> & mut Self :: Target {
190
190
& mut self . body
191
191
}
192
192
}
193
193
194
194
#[ derive( Copy , Clone , Debug ) ]
195
- pub struct ReadOnlyBodyCache < ' a , ' tcx > {
196
- cache : & ' a Cache ,
195
+ pub struct ReadOnlyBodyAndCache < ' a , ' tcx > {
197
196
body : & ' a Body < ' tcx > ,
197
+ cache : & ' a Cache ,
198
198
}
199
199
200
- impl ReadOnlyBodyCache < ' a , ' tcx > {
201
- fn new ( cache : & ' a Cache , body : & ' a Body < ' tcx > ) -> Self {
200
+ impl ReadOnlyBodyAndCache < ' a , ' tcx > {
201
+ fn new ( body : & ' a Body < ' tcx > , cache : & ' a Cache ) -> Self {
202
202
assert ! (
203
203
cache. predecessors. is_some( ) ,
204
- "Cannot construct ReadOnlyBodyCache without computed predecessors" ) ;
204
+ "Cannot construct ReadOnlyBodyAndCache without computed predecessors" ) ;
205
205
Self {
206
- cache,
207
206
body,
207
+ cache,
208
208
}
209
209
}
210
210
@@ -220,10 +220,6 @@ impl ReadOnlyBodyCache<'a, 'tcx> {
220
220
self . cache . unwrap_predecessor_locations ( loc, self . body )
221
221
}
222
222
223
- pub fn body ( & self ) -> & ' a Body < ' tcx > {
224
- self . body
225
- }
226
-
227
223
pub fn basic_blocks ( & self ) -> & IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
228
224
& self . body . basic_blocks
229
225
}
@@ -233,16 +229,16 @@ impl ReadOnlyBodyCache<'a, 'tcx> {
233
229
}
234
230
}
235
231
236
- impl graph:: DirectedGraph for ReadOnlyBodyCache < ' a , ' tcx > {
232
+ impl graph:: DirectedGraph for ReadOnlyBodyAndCache < ' a , ' tcx > {
237
233
type Node = BasicBlock ;
238
234
}
239
235
240
- impl graph:: GraphPredecessors < ' graph > for ReadOnlyBodyCache < ' a , ' tcx > {
236
+ impl graph:: GraphPredecessors < ' graph > for ReadOnlyBodyAndCache < ' a , ' tcx > {
241
237
type Item = BasicBlock ;
242
238
type Iter = IntoIter < BasicBlock > ;
243
239
}
244
240
245
- impl graph:: WithPredecessors for ReadOnlyBodyCache < ' a , ' tcx > {
241
+ impl graph:: WithPredecessors for ReadOnlyBodyAndCache < ' a , ' tcx > {
246
242
fn predecessors (
247
243
& self ,
248
244
node : Self :: Node ,
@@ -251,19 +247,19 @@ impl graph::WithPredecessors for ReadOnlyBodyCache<'a, 'tcx> {
251
247
}
252
248
}
253
249
254
- impl graph:: WithNumNodes for ReadOnlyBodyCache < ' a , ' tcx > {
250
+ impl graph:: WithNumNodes for ReadOnlyBodyAndCache < ' a , ' tcx > {
255
251
fn num_nodes ( & self ) -> usize {
256
252
self . body . num_nodes ( )
257
253
}
258
254
}
259
255
260
- impl graph:: WithStartNode for ReadOnlyBodyCache < ' a , ' tcx > {
256
+ impl graph:: WithStartNode for ReadOnlyBodyAndCache < ' a , ' tcx > {
261
257
fn start_node ( & self ) -> Self :: Node {
262
258
self . body . start_node ( )
263
259
}
264
260
}
265
261
266
- impl graph:: WithSuccessors for ReadOnlyBodyCache < ' a , ' tcx > {
262
+ impl graph:: WithSuccessors for ReadOnlyBodyAndCache < ' a , ' tcx > {
267
263
fn successors (
268
264
& self ,
269
265
node : Self :: Node ,
@@ -272,13 +268,13 @@ impl graph::WithSuccessors for ReadOnlyBodyCache<'a, 'tcx> {
272
268
}
273
269
}
274
270
275
- impl < ' a , ' b , ' tcx > graph:: GraphSuccessors < ' b > for ReadOnlyBodyCache < ' a , ' tcx > {
271
+ impl < ' a , ' b , ' tcx > graph:: GraphSuccessors < ' b > for ReadOnlyBodyAndCache < ' a , ' tcx > {
276
272
type Item = BasicBlock ;
277
273
type Iter = iter:: Cloned < Successors < ' b > > ;
278
274
}
279
275
280
276
281
- impl Deref for ReadOnlyBodyCache < ' a , ' tcx > {
277
+ impl Deref for ReadOnlyBodyAndCache < ' a , ' tcx > {
282
278
type Target = & ' a Body < ' tcx > ;
283
279
284
280
fn deref ( & self ) -> & Self :: Target {
0 commit comments