@@ -244,7 +244,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
244244 . map ( |arm| {
245245 let arm = & self . thir [ arm] ;
246246 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 ) ;
248249 ( arm, arm_candidate)
249250 } )
250251 . collect ( )
@@ -578,7 +579,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
578579 initializer : PlaceBuilder < ' tcx > ,
579580 set_match_place : bool ,
580581 ) -> BlockAnd < ( ) > {
581- let mut candidate = Candidate :: new ( initializer. clone ( ) , & irrefutable_pat, false ) ;
582+ let mut candidate = Candidate :: new ( initializer. clone ( ) , & irrefutable_pat, false , self ) ;
582583 let fake_borrow_temps = self . lower_match_tree (
583584 block,
584585 irrefutable_pat. span ,
@@ -859,11 +860,16 @@ struct Candidate<'pat, 'tcx> {
859860}
860861
861862impl < ' 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 {
863869 Candidate {
864870 span : pattern. span ,
865871 has_guard,
866- match_pairs : smallvec ! [ MatchPair :: new( place, pattern) ] ,
872+ match_pairs : smallvec ! [ MatchPair :: new( place, pattern, cx ) ] ,
867873 bindings : Vec :: new ( ) ,
868874 ascriptions : Vec :: new ( ) ,
869875 subcandidates : Vec :: new ( ) ,
@@ -1383,7 +1389,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
13831389 debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
13841390 let mut or_candidates: Vec < _ > = pats
13851391 . iter ( )
1386- . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard ) )
1392+ . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , self ) )
13871393 . collect ( ) ;
13881394 let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
13891395 let otherwise = if candidate. otherwise_block . is_some ( ) {
@@ -1779,8 +1785,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17791785 let expr_span = expr. span ;
17801786 let expr_place_builder = unpack ! ( block = self . lower_scrutinee( block, expr, expr_span) ) ;
17811787 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 ) ;
17841791 let fake_borrow_temps = self . lower_match_tree (
17851792 block,
17861793 pat. span ,
@@ -2276,8 +2283,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22762283 let ( matching, failure) = self . in_if_then_scope ( * let_else_scope, |this| {
22772284 let scrutinee = unpack ! ( block = this. lower_scrutinee( block, init, initializer_span) ) ;
22782285 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 ) ;
22812288 let fake_borrow_temps = this. lower_match_tree (
22822289 block,
22832290 initializer_span,
0 commit comments