@@ -192,11 +192,7 @@ impl<N: Idx> RegionValues<N> {
192
192
193
193
/// True if `sup_region` contains all the CFG points that
194
194
/// `sub_region` contains. Ignores universal regions.
195
- crate fn contains_points (
196
- & self ,
197
- sup_region : N ,
198
- sub_region : N ,
199
- ) -> bool {
195
+ crate fn contains_points ( & self , sup_region : N , sub_region : N ) -> bool {
200
196
// This could be done faster by comparing the bitsets. But I
201
197
// am lazy.
202
198
if let Some ( sub_row) = self . points . row ( sub_region) {
@@ -252,72 +248,7 @@ impl<N: Idx> RegionValues<N> {
252
248
253
249
/// Returns a "pretty" string value of the region. Meant for debugging.
254
250
crate fn region_value_str ( & self , r : N ) -> String {
255
- let mut result = String :: new ( ) ;
256
- result. push_str ( "{" ) ;
257
-
258
- // Set to Some(l1, l2) when we have observed all the locations
259
- // from l1..=l2 (inclusive) but not yet printed them. This
260
- // gets extended if we then see l3 where l3 is the successor
261
- // to l2.
262
- let mut open_location: Option < ( Location , Location ) > = None ;
263
-
264
- let mut sep = "" ;
265
- let mut push_sep = |s : & mut String | {
266
- s. push_str ( sep) ;
267
- sep = ", " ;
268
- } ;
269
-
270
- for element in self . elements_contained_in ( r) {
271
- match element {
272
- RegionElement :: Location ( l) => {
273
- if let Some ( ( location1, location2) ) = open_location {
274
- if location2. block == l. block
275
- && location2. statement_index == l. statement_index - 1
276
- {
277
- open_location = Some ( ( location1, l) ) ;
278
- continue ;
279
- }
280
-
281
- push_sep ( & mut result) ;
282
- Self :: push_location_range ( & mut result, location1, location2) ;
283
- }
284
-
285
- open_location = Some ( ( l, l) ) ;
286
- }
287
-
288
- RegionElement :: RootUniversalRegion ( fr) => {
289
- if let Some ( ( location1, location2) ) = open_location {
290
- push_sep ( & mut result) ;
291
- Self :: push_location_range ( & mut result, location1, location2) ;
292
- open_location = None ;
293
- }
294
-
295
- push_sep ( & mut result) ;
296
- result. push_str ( & format ! ( "{:?}" , fr) ) ;
297
- }
298
- }
299
- }
300
-
301
- if let Some ( ( location1, location2) ) = open_location {
302
- push_sep ( & mut result) ;
303
- Self :: push_location_range ( & mut result, location1, location2) ;
304
- }
305
-
306
- result. push_str ( "}" ) ;
307
-
308
- result
309
- }
310
-
311
- fn push_location_range ( str : & mut String , location1 : Location , location2 : Location ) {
312
- if location1 == location2 {
313
- str. push_str ( & format ! ( "{:?}" , location1) ) ;
314
- } else {
315
- assert_eq ! ( location1. block, location2. block) ;
316
- str. push_str ( & format ! (
317
- "{:?}[{}..={}]" ,
318
- location1. block, location1. statement_index, location2. statement_index
319
- ) ) ;
320
- }
251
+ region_value_str ( self . elements_contained_in ( r) )
321
252
}
322
253
}
323
254
@@ -372,3 +303,72 @@ impl ToElementIndex for RegionVid {
372
303
values. free_regions . contains ( row, self )
373
304
}
374
305
}
306
+
307
+ crate fn region_value_str ( elements : impl IntoIterator < Item = RegionElement > ) -> String {
308
+ let mut result = String :: new ( ) ;
309
+ result. push_str ( "{" ) ;
310
+
311
+ // Set to Some(l1, l2) when we have observed all the locations
312
+ // from l1..=l2 (inclusive) but not yet printed them. This
313
+ // gets extended if we then see l3 where l3 is the successor
314
+ // to l2.
315
+ let mut open_location: Option < ( Location , Location ) > = None ;
316
+
317
+ let mut sep = "" ;
318
+ let mut push_sep = |s : & mut String | {
319
+ s. push_str ( sep) ;
320
+ sep = ", " ;
321
+ } ;
322
+
323
+ for element in elements {
324
+ match element {
325
+ RegionElement :: Location ( l) => {
326
+ if let Some ( ( location1, location2) ) = open_location {
327
+ if location2. block == l. block
328
+ && location2. statement_index == l. statement_index - 1
329
+ {
330
+ open_location = Some ( ( location1, l) ) ;
331
+ continue ;
332
+ }
333
+
334
+ push_sep ( & mut result) ;
335
+ push_location_range ( & mut result, location1, location2) ;
336
+ }
337
+
338
+ open_location = Some ( ( l, l) ) ;
339
+ }
340
+
341
+ RegionElement :: RootUniversalRegion ( fr) => {
342
+ if let Some ( ( location1, location2) ) = open_location {
343
+ push_sep ( & mut result) ;
344
+ push_location_range ( & mut result, location1, location2) ;
345
+ open_location = None ;
346
+ }
347
+
348
+ push_sep ( & mut result) ;
349
+ result. push_str ( & format ! ( "{:?}" , fr) ) ;
350
+ }
351
+ }
352
+ }
353
+
354
+ if let Some ( ( location1, location2) ) = open_location {
355
+ push_sep ( & mut result) ;
356
+ push_location_range ( & mut result, location1, location2) ;
357
+ }
358
+
359
+ result. push_str ( "}" ) ;
360
+
361
+ return result;
362
+
363
+ fn push_location_range ( str : & mut String , location1 : Location , location2 : Location ) {
364
+ if location1 == location2 {
365
+ str. push_str ( & format ! ( "{:?}" , location1) ) ;
366
+ } else {
367
+ assert_eq ! ( location1. block, location2. block) ;
368
+ str. push_str ( & format ! (
369
+ "{:?}[{}..={}]" ,
370
+ location1. block, location1. statement_index, location2. statement_index
371
+ ) ) ;
372
+ }
373
+ }
374
+ }
0 commit comments