@@ -122,8 +122,8 @@ impl Candidate {
122
122
/// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
123
123
fn forces_explicit_promotion ( & self ) -> bool {
124
124
match self {
125
- Candidate :: Ref ( _) | Candidate :: Repeat ( _ ) => false ,
126
- Candidate :: Argument { .. } => true ,
125
+ Candidate :: Ref ( _) => false ,
126
+ Candidate :: Argument { .. } | Candidate :: Repeat ( _ ) => true ,
127
127
}
128
128
}
129
129
}
@@ -203,14 +203,20 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
203
203
fn visit_rvalue ( & mut self , rvalue : & Rvalue < ' tcx > , location : Location ) {
204
204
self . super_rvalue ( rvalue, location) ;
205
205
206
- match * rvalue {
206
+ match rvalue {
207
207
Rvalue :: Ref ( ..) => {
208
208
self . candidates . push ( Candidate :: Ref ( location) ) ;
209
209
}
210
- Rvalue :: Repeat ( ..) if self . ccx . tcx . features ( ) . const_in_array_repeat_expressions => {
211
- // FIXME(#49147) only promote the element when it isn't `Copy`
212
- // (so that code that can copy it at runtime is unaffected).
213
- self . candidates . push ( Candidate :: Repeat ( location) ) ;
210
+ Rvalue :: Repeat ( elem, _)
211
+ if self . ccx . tcx . features ( ) . const_in_array_repeat_expressions =>
212
+ {
213
+ if !elem. ty ( & self . ccx . body . local_decls , self . ccx . tcx ) . is_copy_modulo_regions (
214
+ self . ccx . tcx ,
215
+ self . ccx . param_env ,
216
+ self . span ,
217
+ ) {
218
+ self . candidates . push ( Candidate :: Repeat ( location) ) ;
219
+ }
214
220
}
215
221
_ => { }
216
222
}
@@ -380,7 +386,7 @@ impl<'tcx> Validator<'_, 'tcx> {
380
386
}
381
387
}
382
388
Candidate :: Repeat ( loc) => {
383
- assert ! ( ! self . explicit) ;
389
+ assert ! ( self . explicit) ;
384
390
385
391
let statement = & self . body [ loc. block ] . statements [ loc. statement_index ] ;
386
392
match & statement. kind {
0 commit comments