@@ -1067,30 +1067,28 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
10671067 } ;
10681068 debug ! ( "qualify_const: promotion_candidates={:?}" , promotion_candidates) ;
10691069 for candidate in promotion_candidates {
1070- match candidate {
1070+ let promoted_place = match candidate {
10711071 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 ,
10791076 }
10801077 }
10811078 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 ,
10911082 }
10921083 }
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+ _ => { }
10941092 }
10951093 }
10961094
0 commit comments