@@ -1065,30 +1065,23 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
10651065 } else {
10661066 self . valid_promotion_candidates ( )
10671067 } ;
1068+
10681069 debug ! ( "qualify_const: promotion_candidates={:?}" , promotion_candidates) ;
10691070 for candidate in promotion_candidates {
1070- let promoted_place = match candidate {
1071- Candidate :: Repeat ( Location { block : bb, statement_index : stmt_idx } ) => {
1072- match & self . body [ bb] . statements [ stmt_idx] . kind {
1073- StatementKind :: Assign ( box( _, Rvalue :: Repeat ( Operand :: Move ( place) , _) ) )
1074- => place,
1075- _ => continue ,
1076- }
1077- }
1071+ match candidate {
10781072 Candidate :: Ref ( Location { block : bb, statement_index : stmt_idx } ) => {
1079- match & self . body [ bb] . statements [ stmt_idx] . kind {
1080- StatementKind :: Assign ( box( _, Rvalue :: Ref ( _, _, place) ) ) => place,
1081- _ => continue ,
1073+ if let StatementKind :: Assign ( box( _, Rvalue :: Ref ( _, _, place) ) )
1074+ = & self . body [ bb] . statements [ stmt_idx] . kind
1075+ {
1076+ if let PlaceBase :: Local ( local) = place. base {
1077+ promoted_temps. insert ( local) ;
1078+ }
10821079 }
10831080 }
1084- Candidate :: Argument { .. } => continue ,
1085- } ;
10861081
1087- match promoted_place. base {
1088- PlaceBase :: Local ( local) if !promoted_place. is_indirect ( ) => {
1089- promoted_temps. insert ( local) ;
1090- }
1091- _ => { }
1082+ // Only rvalue-static promotion requires extending the lifetime of the promoted
1083+ // local.
1084+ Candidate :: Argument { .. } | Candidate :: Repeat ( _) => { }
10921085 }
10931086 }
10941087
0 commit comments