@@ -1065,30 +1065,23 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
1065
1065
} else {
1066
1066
self . valid_promotion_candidates ( )
1067
1067
} ;
1068
+
1068
1069
debug ! ( "qualify_const: promotion_candidates={:?}" , promotion_candidates) ;
1069
1070
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 {
1078
1072
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
+ }
1082
1079
}
1083
1080
}
1084
- Candidate :: Argument { .. } => continue ,
1085
- } ;
1086
1081
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 ( _) => { }
1092
1085
}
1093
1086
}
1094
1087
0 commit comments