@@ -244,7 +244,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
244
244
. map ( |arm| {
245
245
let arm = & self . thir [ arm] ;
246
246
let arm_has_guard = arm. guard . is_some ( ) ;
247
- let arm_candidate = Candidate :: new ( scrutinee. clone ( ) , & arm. pattern , arm_has_guard) ;
247
+ let arm_candidate =
248
+ Candidate :: new ( scrutinee. clone ( ) , & arm. pattern , arm_has_guard, self ) ;
248
249
( arm, arm_candidate)
249
250
} )
250
251
. collect ( )
@@ -578,7 +579,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
578
579
initializer : PlaceBuilder < ' tcx > ,
579
580
set_match_place : bool ,
580
581
) -> BlockAnd < ( ) > {
581
- let mut candidate = Candidate :: new ( initializer. clone ( ) , & irrefutable_pat, false ) ;
582
+ let mut candidate = Candidate :: new ( initializer. clone ( ) , & irrefutable_pat, false , self ) ;
582
583
let fake_borrow_temps = self . lower_match_tree (
583
584
block,
584
585
irrefutable_pat. span ,
@@ -859,11 +860,16 @@ struct Candidate<'pat, 'tcx> {
859
860
}
860
861
861
862
impl < ' tcx , ' pat > Candidate < ' pat , ' tcx > {
862
- fn new ( place : PlaceBuilder < ' tcx > , pattern : & ' pat Pat < ' tcx > , has_guard : bool ) -> Self {
863
+ fn new (
864
+ place : PlaceBuilder < ' tcx > ,
865
+ pattern : & ' pat Pat < ' tcx > ,
866
+ has_guard : bool ,
867
+ cx : & Builder < ' _ , ' tcx > ,
868
+ ) -> Self {
863
869
Candidate {
864
870
span : pattern. span ,
865
871
has_guard,
866
- match_pairs : smallvec ! [ MatchPair :: new( place, pattern) ] ,
872
+ match_pairs : smallvec ! [ MatchPair :: new( place, pattern, cx ) ] ,
867
873
bindings : Vec :: new ( ) ,
868
874
ascriptions : Vec :: new ( ) ,
869
875
subcandidates : Vec :: new ( ) ,
@@ -1383,7 +1389,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1383
1389
debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
1384
1390
let mut or_candidates: Vec < _ > = pats
1385
1391
. iter ( )
1386
- . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard ) )
1392
+ . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , self ) )
1387
1393
. collect ( ) ;
1388
1394
let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
1389
1395
let otherwise = if candidate. otherwise_block . is_some ( ) {
@@ -1779,8 +1785,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1779
1785
let expr_span = expr. span ;
1780
1786
let expr_place_builder = unpack ! ( block = self . lower_scrutinee( block, expr, expr_span) ) ;
1781
1787
let wildcard = Pat :: wildcard_from_ty ( pat. ty ) ;
1782
- let mut guard_candidate = Candidate :: new ( expr_place_builder. clone ( ) , & pat, false ) ;
1783
- let mut otherwise_candidate = Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false ) ;
1788
+ let mut guard_candidate = Candidate :: new ( expr_place_builder. clone ( ) , & pat, false , self ) ;
1789
+ let mut otherwise_candidate =
1790
+ Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false , self ) ;
1784
1791
let fake_borrow_temps = self . lower_match_tree (
1785
1792
block,
1786
1793
pat. span ,
@@ -2276,8 +2283,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2276
2283
let ( matching, failure) = self . in_if_then_scope ( * let_else_scope, |this| {
2277
2284
let scrutinee = unpack ! ( block = this. lower_scrutinee( block, init, initializer_span) ) ;
2278
2285
let pat = Pat { ty : init. ty , span : else_block_span, kind : PatKind :: Wild } ;
2279
- let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false ) ;
2280
- let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false ) ;
2286
+ let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false , this ) ;
2287
+ let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false , this ) ;
2281
2288
let fake_borrow_temps = this. lower_match_tree (
2282
2289
block,
2283
2290
initializer_span,
0 commit comments