@@ -1065,8 +1065,6 @@ pub(crate) struct ArmHasGuard(pub(crate) bool);
1065
1065
1066
1066
/// A single step in the match algorithm.
1067
1067
pub ( crate ) struct MatchAutomatonStep < ' a , ' c , ' pat , ' tcx > {
1068
- /// FIXME: probably the span of the match.
1069
- span : Span ,
1070
1068
/// Perform this test...
1071
1069
test : Test < ' tcx > ,
1072
1070
/// ... on this place...
@@ -1112,7 +1110,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1112
1110
/// exhaustive in Rust. But during processing we sometimes divide
1113
1111
/// up the list of candidates and recurse with a non-exhaustive
1114
1112
/// list. This is important to keep the size of the generated code
1115
- /// under control. See [`Builder::test_candidates `] for more details.
1113
+ /// under control. See [`Builder::build_test_step `] for more details.
1116
1114
///
1117
1115
/// If `fake_borrows` is `Some`, then places which need fake borrows
1118
1116
/// will be added to it.
@@ -1348,7 +1346,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1348
1346
}
1349
1347
1350
1348
/// Tests a candidate where there are only or-patterns left to test, or
1351
- /// forwards to [Builder::test_candidates ].
1349
+ /// forwards to [Builder::build_test_step ].
1352
1350
///
1353
1351
/// Given a pattern `(P | Q, R | S)` we (in principle) generate a CFG like
1354
1352
/// so:
@@ -1416,14 +1414,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1416
1414
match first_candidate. match_pairs [ 0 ] . pattern . kind {
1417
1415
PatKind :: Or { .. } => ( ) ,
1418
1416
_ => {
1419
- self . test_candidates (
1420
- span,
1421
- scrutinee_span,
1422
- candidates,
1423
- block,
1424
- otherwise_block,
1425
- fake_borrows,
1426
- ) ;
1417
+ let step = self . build_test_step ( candidates, otherwise_block, fake_borrows) ;
1418
+ self . perform_test ( span, scrutinee_span, block, step) ;
1427
1419
return ;
1428
1420
}
1429
1421
}
@@ -1653,15 +1645,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1653
1645
/// In addition to avoiding exponential-time blowups, this algorithm
1654
1646
/// also has the nice property that each guard and arm is only generated
1655
1647
/// once.
1656
- fn test_candidates < ' pat , ' b , ' c > (
1648
+ fn build_test_step < ' pat , ' b , ' c > (
1657
1649
& mut self ,
1658
- span : Span ,
1659
- scrutinee_span : Span ,
1660
1650
mut candidates : & ' b mut [ & ' c mut Candidate < ' pat , ' tcx > ] ,
1661
- block : BasicBlock ,
1662
- otherwise_block : & mut Option < BasicBlock > ,
1663
- fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1664
- ) {
1651
+ otherwise_block : & ' b mut Option < BasicBlock > ,
1652
+ fake_borrows : & ' b mut Option < FxIndexSet < Place < ' tcx > > > ,
1653
+ ) -> MatchAutomatonStep < ' b , ' c , ' pat , ' tcx > {
1665
1654
// extract the match-pair from the highest priority candidate
1666
1655
let match_pair = & candidates. first ( ) . unwrap ( ) . match_pairs [ 0 ] ;
1667
1656
let mut test = self . test ( match_pair) ;
@@ -1700,7 +1689,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1700
1689
// those N possible outcomes, create a (initially empty)
1701
1690
// vector of candidates. Those are the candidates that still
1702
1691
// apply if the test has that particular outcome.
1703
- debug ! ( "test_candidates : test={:?} match_pair={:?}" , test, match_pair) ;
1692
+ debug ! ( "build_test_step : test={:?} match_pair={:?}" , test, match_pair) ;
1704
1693
let mut target_candidates: Vec < Vec < & mut Candidate < ' pat , ' tcx > > > = vec ! [ ] ;
1705
1694
target_candidates. resize_with ( test. targets ( ) , Default :: default) ;
1706
1695
@@ -1726,16 +1715,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1726
1715
debug ! ( "tested_candidates: {}" , total_candidate_count - candidates. len( ) ) ;
1727
1716
debug ! ( "untested_candidates: {}" , candidates. len( ) ) ;
1728
1717
1729
- let step = MatchAutomatonStep {
1730
- span,
1718
+ MatchAutomatonStep {
1731
1719
test,
1732
1720
place : match_place,
1733
1721
remaining_candidates : candidates,
1734
1722
target_candidates,
1735
1723
otherwise_block,
1736
1724
fake_borrows,
1737
- } ;
1738
- self . perform_test ( span, scrutinee_span, block, step) ;
1725
+ }
1739
1726
}
1740
1727
1741
1728
/// Determine the fake borrows that are needed from a set of places that
0 commit comments