@@ -315,21 +315,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
315
315
// The set of places that we are creating fake borrows of. If there are
316
316
// no match guards then we don't need any fake borrows, so don't track
317
317
// them.
318
- let mut fake_borrows = match_has_guard
318
+ let fake_borrows = match_has_guard
319
319
. then ( || util:: FakeBorrowCollector :: collect_fake_borrows ( self , candidates) ) ;
320
320
321
321
let otherwise_block = self . cfg . start_new_block ( ) ;
322
322
323
323
// This will generate code to test scrutinee_place and
324
324
// branch to the appropriate arm block
325
- self . match_candidates (
326
- match_start_span,
327
- scrutinee_span,
328
- block,
329
- otherwise_block,
330
- candidates,
331
- & mut fake_borrows,
332
- ) ;
325
+ self . match_candidates ( match_start_span, scrutinee_span, block, otherwise_block, candidates) ;
333
326
334
327
// See the doc comment on `match_candidates` for why we may have an
335
328
// otherwise block. Match checking will ensure this is actually
@@ -1236,15 +1229,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1236
1229
///
1237
1230
/// Note how we test `x` twice. This is the tradeoff of backtracking automata: we prefer smaller
1238
1231
/// code size at the expense of non-optimal code paths.
1239
- #[ instrument( skip( self , fake_borrows ) , level = "debug" ) ]
1232
+ #[ instrument( skip( self ) , level = "debug" ) ]
1240
1233
fn match_candidates < ' pat > (
1241
1234
& mut self ,
1242
1235
span : Span ,
1243
1236
scrutinee_span : Span ,
1244
1237
start_block : BasicBlock ,
1245
1238
otherwise_block : BasicBlock ,
1246
1239
candidates : & mut [ & mut Candidate < ' pat , ' tcx > ] ,
1247
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1248
1240
) {
1249
1241
let mut split_or_candidate = false ;
1250
1242
for candidate in & mut * candidates {
@@ -1281,7 +1273,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1281
1273
start_block,
1282
1274
otherwise_block,
1283
1275
& mut * new_candidates,
1284
- fake_borrows,
1285
1276
) ;
1286
1277
} else {
1287
1278
self . match_simplified_candidates (
@@ -1290,7 +1281,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1290
1281
start_block,
1291
1282
otherwise_block,
1292
1283
candidates,
1293
- fake_borrows,
1294
1284
) ;
1295
1285
}
1296
1286
} ) ;
@@ -1303,7 +1293,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1303
1293
mut start_block : BasicBlock ,
1304
1294
otherwise_block : BasicBlock ,
1305
1295
candidates : & mut [ & mut Candidate < ' _ , ' tcx > ] ,
1306
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1307
1296
) {
1308
1297
match candidates {
1309
1298
[ ] => {
@@ -1315,14 +1304,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1315
1304
[ first, remaining @ ..] if first. match_pairs . is_empty ( ) => {
1316
1305
// The first candidate has satisfied all its match pairs; we link it up and continue
1317
1306
// with the remaining candidates.
1318
- start_block = self . select_matched_candidate ( first, start_block, fake_borrows ) ;
1307
+ start_block = self . select_matched_candidate ( first, start_block) ;
1319
1308
self . match_simplified_candidates (
1320
1309
span,
1321
1310
scrutinee_span,
1322
1311
start_block,
1323
1312
otherwise_block,
1324
1313
remaining,
1325
- fake_borrows,
1326
1314
)
1327
1315
}
1328
1316
candidates => {
@@ -1333,7 +1321,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1333
1321
candidates,
1334
1322
start_block,
1335
1323
otherwise_block,
1336
- fake_borrows,
1337
1324
) ;
1338
1325
}
1339
1326
}
@@ -1368,7 +1355,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1368
1355
& mut self ,
1369
1356
candidate : & mut Candidate < ' _ , ' tcx > ,
1370
1357
start_block : BasicBlock ,
1371
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1372
1358
) -> BasicBlock {
1373
1359
assert ! ( candidate. otherwise_block. is_none( ) ) ;
1374
1360
assert ! ( candidate. pre_binding_block. is_none( ) ) ;
@@ -1444,19 +1430,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1444
1430
candidates : & mut [ & mut Candidate < ' _ , ' tcx > ] ,
1445
1431
start_block : BasicBlock ,
1446
1432
otherwise_block : BasicBlock ,
1447
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1448
1433
) {
1449
1434
let ( first_candidate, remaining_candidates) = candidates. split_first_mut ( ) . unwrap ( ) ;
1450
1435
assert ! ( first_candidate. subcandidates. is_empty( ) ) ;
1451
1436
if !matches ! ( first_candidate. match_pairs[ 0 ] . test_case, TestCase :: Or { .. } ) {
1452
- self . test_candidates (
1453
- span,
1454
- scrutinee_span,
1455
- candidates,
1456
- start_block,
1457
- otherwise_block,
1458
- fake_borrows,
1459
- ) ;
1437
+ self . test_candidates ( span, scrutinee_span, candidates, start_block, otherwise_block) ;
1460
1438
return ;
1461
1439
}
1462
1440
@@ -1467,14 +1445,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1467
1445
let remainder_start = self . cfg . start_new_block ( ) ;
1468
1446
let or_span = first_match_pair. pattern . span ;
1469
1447
// Test the alternatives of this or-pattern.
1470
- self . test_or_pattern (
1471
- first_candidate,
1472
- start_block,
1473
- remainder_start,
1474
- pats,
1475
- or_span,
1476
- fake_borrows,
1477
- ) ;
1448
+ self . test_or_pattern ( first_candidate, start_block, remainder_start, pats, or_span) ;
1478
1449
1479
1450
if !remaining_match_pairs. is_empty ( ) {
1480
1451
// If more match pairs remain, test them after each subcandidate.
@@ -1495,7 +1466,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1495
1466
& mut [ leaf_candidate] ,
1496
1467
or_start,
1497
1468
or_otherwise,
1498
- fake_borrows,
1499
1469
) ;
1500
1470
} ) ;
1501
1471
}
@@ -1507,12 +1477,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1507
1477
remainder_start,
1508
1478
otherwise_block,
1509
1479
remaining_candidates,
1510
- fake_borrows,
1511
1480
) ;
1512
1481
}
1513
1482
1514
1483
#[ instrument(
1515
- skip( self , start_block, otherwise_block, or_span, fake_borrows , candidate, pats) ,
1484
+ skip( self , start_block, otherwise_block, or_span, candidate, pats) ,
1516
1485
level = "debug"
1517
1486
) ]
1518
1487
fn test_or_pattern < ' pat > (
@@ -1522,7 +1491,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1522
1491
otherwise_block : BasicBlock ,
1523
1492
pats : & [ FlatPat < ' pat , ' tcx > ] ,
1524
1493
or_span : Span ,
1525
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1526
1494
) {
1527
1495
debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
1528
1496
let mut or_candidates: Vec < _ > = pats
@@ -1537,7 +1505,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1537
1505
start_block,
1538
1506
otherwise_block,
1539
1507
& mut or_candidate_refs,
1540
- fake_borrows,
1541
1508
) ;
1542
1509
candidate. subcandidates = or_candidates;
1543
1510
self . merge_trivial_subcandidates ( candidate, self . source_info ( or_span) ) ;
@@ -1597,7 +1564,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1597
1564
fn pick_test (
1598
1565
& mut self ,
1599
1566
candidates : & mut [ & mut Candidate < ' _ , ' tcx > ] ,
1600
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1601
1567
) -> ( PlaceBuilder < ' tcx > , Test < ' tcx > ) {
1602
1568
// Extract the match-pair from the highest priority candidate
1603
1569
let match_pair = & candidates. first ( ) . unwrap ( ) . match_pairs [ 0 ] ;
@@ -1799,10 +1765,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1799
1765
candidates : & ' b mut [ & ' c mut Candidate < ' pat , ' tcx > ] ,
1800
1766
start_block : BasicBlock ,
1801
1767
otherwise_block : BasicBlock ,
1802
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1803
1768
) {
1804
1769
// Extract the match-pair from the highest priority candidate and build a test from it.
1805
- let ( match_place, test) = self . pick_test ( candidates, fake_borrows ) ;
1770
+ let ( match_place, test) = self . pick_test ( candidates) ;
1806
1771
1807
1772
// For each of the N possible test outcomes, build the vector of candidates that applies if
1808
1773
// the test has that particular outcome.
@@ -1819,7 +1784,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1819
1784
remainder_start,
1820
1785
otherwise_block,
1821
1786
remaining_candidates,
1822
- fake_borrows,
1823
1787
) ;
1824
1788
remainder_start
1825
1789
} else {
@@ -1841,7 +1805,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1841
1805
candidate_start,
1842
1806
remainder_start,
1843
1807
& mut * candidates,
1844
- fake_borrows,
1845
1808
) ;
1846
1809
candidate_start
1847
1810
} else {
0 commit comments