@@ -115,16 +115,16 @@ impl Cache {
115115}
116116
117117#[ derive( Clone , Debug , HashStable , RustcEncodable , RustcDecodable , TypeFoldable ) ]
118- pub struct BodyCache < ' tcx > {
119- cache : Cache ,
118+ pub struct BodyAndCache < ' tcx > {
120119 body : Body < ' tcx > ,
120+ cache : Cache ,
121121}
122122
123- impl BodyCache < ' tcx > {
123+ impl BodyAndCache < ' tcx > {
124124 pub fn new ( body : Body < ' tcx > ) -> Self {
125125 Self {
126- cache : Cache :: new ( ) ,
127126 body,
127+ cache : Cache :: new ( ) ,
128128 }
129129 }
130130}
@@ -139,7 +139,7 @@ macro_rules! read_only {
139139 } ;
140140}
141141
142- impl BodyCache < ' tcx > {
142+ impl BodyAndCache < ' tcx > {
143143 pub fn ensure_predecessors ( & mut self ) {
144144 self . cache . ensure_predecessors ( & self . body ) ;
145145 }
@@ -148,8 +148,8 @@ impl BodyCache<'tcx> {
148148 self . cache . predecessors ( & self . body )
149149 }
150150
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 )
153153 }
154154
155155 pub fn basic_blocks_mut ( & mut self ) -> & mut IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
@@ -163,48 +163,48 @@ impl BodyCache<'tcx> {
163163 }
164164}
165165
166- impl < ' tcx > Index < BasicBlock > for BodyCache < ' tcx > {
166+ impl < ' tcx > Index < BasicBlock > for BodyAndCache < ' tcx > {
167167 type Output = BasicBlockData < ' tcx > ;
168168
169169 fn index ( & self , index : BasicBlock ) -> & BasicBlockData < ' tcx > {
170170 & self . body [ index]
171171 }
172172}
173173
174- impl < ' tcx > IndexMut < BasicBlock > for BodyCache < ' tcx > {
174+ impl < ' tcx > IndexMut < BasicBlock > for BodyAndCache < ' tcx > {
175175 fn index_mut ( & mut self , index : BasicBlock ) -> & mut Self :: Output {
176176 & mut self . basic_blocks_mut ( ) [ index]
177177 }
178178}
179179
180- impl < ' tcx > Deref for BodyCache < ' tcx > {
180+ impl < ' tcx > Deref for BodyAndCache < ' tcx > {
181181 type Target = Body < ' tcx > ;
182182
183183 fn deref ( & self ) -> & Self :: Target {
184184 & self . body
185185 }
186186}
187187
188- impl < ' tcx > DerefMut for BodyCache < ' tcx > {
188+ impl < ' tcx > DerefMut for BodyAndCache < ' tcx > {
189189 fn deref_mut ( & mut self ) -> & mut Self :: Target {
190190 & mut self . body
191191 }
192192}
193193
194194#[ derive( Copy , Clone , Debug ) ]
195- pub struct ReadOnlyBodyCache < ' a , ' tcx > {
196- cache : & ' a Cache ,
195+ pub struct ReadOnlyBodyAndCache < ' a , ' tcx > {
197196 body : & ' a Body < ' tcx > ,
197+ cache : & ' a Cache ,
198198}
199199
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 {
202202 assert ! (
203203 cache. predecessors. is_some( ) ,
204- "Cannot construct ReadOnlyBodyCache without computed predecessors" ) ;
204+ "Cannot construct ReadOnlyBodyAndCache without computed predecessors" ) ;
205205 Self {
206- cache,
207206 body,
207+ cache,
208208 }
209209 }
210210
@@ -220,10 +220,6 @@ impl ReadOnlyBodyCache<'a, 'tcx> {
220220 self . cache . unwrap_predecessor_locations ( loc, self . body )
221221 }
222222
223- pub fn body ( & self ) -> & ' a Body < ' tcx > {
224- self . body
225- }
226-
227223 pub fn basic_blocks ( & self ) -> & IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
228224 & self . body . basic_blocks
229225 }
@@ -233,16 +229,16 @@ impl ReadOnlyBodyCache<'a, 'tcx> {
233229 }
234230}
235231
236- impl graph:: DirectedGraph for ReadOnlyBodyCache < ' a , ' tcx > {
232+ impl graph:: DirectedGraph for ReadOnlyBodyAndCache < ' a , ' tcx > {
237233 type Node = BasicBlock ;
238234}
239235
240- impl graph:: GraphPredecessors < ' graph > for ReadOnlyBodyCache < ' a , ' tcx > {
236+ impl graph:: GraphPredecessors < ' graph > for ReadOnlyBodyAndCache < ' a , ' tcx > {
241237 type Item = BasicBlock ;
242238 type Iter = IntoIter < BasicBlock > ;
243239}
244240
245- impl graph:: WithPredecessors for ReadOnlyBodyCache < ' a , ' tcx > {
241+ impl graph:: WithPredecessors for ReadOnlyBodyAndCache < ' a , ' tcx > {
246242 fn predecessors (
247243 & self ,
248244 node : Self :: Node ,
@@ -251,19 +247,19 @@ impl graph::WithPredecessors for ReadOnlyBodyCache<'a, 'tcx> {
251247 }
252248}
253249
254- impl graph:: WithNumNodes for ReadOnlyBodyCache < ' a , ' tcx > {
250+ impl graph:: WithNumNodes for ReadOnlyBodyAndCache < ' a , ' tcx > {
255251 fn num_nodes ( & self ) -> usize {
256252 self . body . num_nodes ( )
257253 }
258254}
259255
260- impl graph:: WithStartNode for ReadOnlyBodyCache < ' a , ' tcx > {
256+ impl graph:: WithStartNode for ReadOnlyBodyAndCache < ' a , ' tcx > {
261257 fn start_node ( & self ) -> Self :: Node {
262258 self . body . start_node ( )
263259 }
264260}
265261
266- impl graph:: WithSuccessors for ReadOnlyBodyCache < ' a , ' tcx > {
262+ impl graph:: WithSuccessors for ReadOnlyBodyAndCache < ' a , ' tcx > {
267263 fn successors (
268264 & self ,
269265 node : Self :: Node ,
@@ -272,13 +268,13 @@ impl graph::WithSuccessors for ReadOnlyBodyCache<'a, 'tcx> {
272268 }
273269}
274270
275- impl < ' a , ' b , ' tcx > graph:: GraphSuccessors < ' b > for ReadOnlyBodyCache < ' a , ' tcx > {
271+ impl < ' a , ' b , ' tcx > graph:: GraphSuccessors < ' b > for ReadOnlyBodyAndCache < ' a , ' tcx > {
276272 type Item = BasicBlock ;
277273 type Iter = iter:: Cloned < Successors < ' b > > ;
278274}
279275
280276
281- impl Deref for ReadOnlyBodyCache < ' a , ' tcx > {
277+ impl Deref for ReadOnlyBodyAndCache < ' a , ' tcx > {
282278 type Target = & ' a Body < ' tcx > ;
283279
284280 fn deref ( & self ) -> & Self :: Target {
0 commit comments