1
1
use std:: fmt;
2
2
3
3
use rustc_data_structures:: fx:: FxIndexMap ;
4
- use rustc_data_structures:: graph;
5
4
use rustc_index:: bit_set:: DenseBitSet ;
6
5
use rustc_middle:: mir:: {
7
6
self , BasicBlock , Body , CallReturnPlaces , Location , Place , TerminatorEdges ,
@@ -317,9 +316,8 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
317
316
loans_out_of_scope_at_location : FxIndexMap :: default ( ) ,
318
317
} ;
319
318
for ( loan_idx, loan_data) in borrow_set. iter_enumerated ( ) {
320
- let issuing_region = loan_data. region ;
321
319
let loan_issued_at = loan_data. reserve_location ;
322
- prec. precompute_loans_out_of_scope ( loan_idx, issuing_region , loan_issued_at) ;
320
+ prec. precompute_loans_out_of_scope ( loan_idx, loan_issued_at) ;
323
321
}
324
322
325
323
prec. loans_out_of_scope_at_location
@@ -328,45 +326,7 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
328
326
/// Loans are in scope while they are live: whether they are contained within any live region.
329
327
/// In the location-insensitive analysis, a loan will be contained in a region if the issuing
330
328
/// region can reach it in the subset graph. So this is a reachability problem.
331
- fn precompute_loans_out_of_scope (
332
- & mut self ,
333
- loan_idx : BorrowIndex ,
334
- issuing_region : RegionVid ,
335
- loan_issued_at : Location ,
336
- ) {
337
- let sccs = self . regioncx . constraint_sccs ( ) ;
338
- let universal_regions = self . regioncx . universal_regions ( ) ;
339
-
340
- // The loop below was useful for the location-insensitive analysis but shouldn't be
341
- // impactful in the location-sensitive case. It seems that it does, however, as without it a
342
- // handful of tests fail. That likely means some liveness or outlives data related to choice
343
- // regions is missing
344
- // FIXME: investigate the impact of loans traversing applied member constraints and why some
345
- // tests fail otherwise.
346
- //
347
- // We first handle the cases where the loan doesn't go out of scope, depending on the
348
- // issuing region's successors.
349
- for successor in graph:: depth_first_search ( & self . regioncx . region_graph ( ) , issuing_region) {
350
- // Via applied member constraints
351
- //
352
- // The issuing region can flow into the choice regions, and they are either:
353
- // - placeholders or free regions themselves,
354
- // - or also transitively outlive a free region.
355
- //
356
- // That is to say, if there are applied member constraints here, the loan escapes the
357
- // function and cannot go out of scope. We could early return here.
358
- //
359
- // For additional insurance via fuzzing and crater, we verify that the constraint's min
360
- // choice indeed escapes the function. In the future, we could e.g. turn this check into
361
- // a debug assert and early return as an optimization.
362
- let scc = sccs. scc ( successor) ;
363
- for constraint in self . regioncx . applied_member_constraints ( scc) {
364
- if universal_regions. is_universal_region ( constraint. min_choice ) {
365
- return ;
366
- }
367
- }
368
- }
369
-
329
+ fn precompute_loans_out_of_scope ( & mut self , loan_idx : BorrowIndex , loan_issued_at : Location ) {
370
330
let first_block = loan_issued_at. block ;
371
331
let first_bb_data = & self . body . basic_blocks [ first_block] ;
372
332
0 commit comments