@@ -1067,30 +1067,28 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
1067
1067
} ;
1068
1068
debug ! ( "qualify_const: promotion_candidates={:?}" , promotion_candidates) ;
1069
1069
for candidate in promotion_candidates {
1070
- match candidate {
1070
+ let promoted_place = match candidate {
1071
1071
Candidate :: Repeat ( Location { block : bb, statement_index : stmt_idx } ) => {
1072
- if let StatementKind :: Assign ( box( _, Rvalue :: Repeat (
1073
- Operand :: Move ( place) ,
1074
- _
1075
- ) ) ) = & self . body [ bb] . statements [ stmt_idx] . kind {
1076
- if let Some ( index) = place. as_local ( ) {
1077
- promoted_temps. insert ( index) ;
1078
- }
1072
+ match & self . body [ bb] . statements [ stmt_idx] . kind {
1073
+ StatementKind :: Assign ( box( _, Rvalue :: Repeat ( Operand :: Move ( place) , _) ) )
1074
+ => place,
1075
+ _ => continue ,
1079
1076
}
1080
1077
}
1081
1078
Candidate :: Ref ( Location { block : bb, statement_index : stmt_idx } ) => {
1082
- if let StatementKind :: Assign (
1083
- box(
1084
- _,
1085
- Rvalue :: Ref ( _, _, place)
1086
- )
1087
- ) = & self . body [ bb] . statements [ stmt_idx] . kind {
1088
- if let Some ( index) = place. as_local ( ) {
1089
- promoted_temps. insert ( index) ;
1090
- }
1079
+ match & self . body [ bb] . statements [ stmt_idx] . kind {
1080
+ StatementKind :: Assign ( box( _, Rvalue :: Ref ( _, _, place) ) ) => place,
1081
+ _ => continue ,
1091
1082
}
1092
1083
}
1093
- Candidate :: Argument { .. } => { }
1084
+ Candidate :: Argument { .. } => continue ,
1085
+ } ;
1086
+
1087
+ match promoted_place. base {
1088
+ PlaceBase :: Local ( local) if !promoted_place. is_indirect ( ) => {
1089
+ promoted_temps. insert ( local) ;
1090
+ }
1091
+ _ => { }
1094
1092
}
1095
1093
}
1096
1094
0 commit comments