@@ -102,9 +102,6 @@ pub enum Candidate {
102
102
/// Borrow of a constant temporary, candidate for lifetime extension.
103
103
Ref ( Location ) ,
104
104
105
- /// Promotion of the `x` in `[x; 32]`.
106
- Repeat ( Location ) ,
107
-
108
105
/// Currently applied to function calls where the callee has the unstable
109
106
/// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle
110
107
/// intrinsic. The intrinsic requires the arguments are indeed constant and
@@ -120,14 +117,14 @@ impl Candidate {
120
117
/// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
121
118
fn forces_explicit_promotion ( & self ) -> bool {
122
119
match self {
123
- Candidate :: Ref ( _) | Candidate :: Repeat ( _ ) => false ,
120
+ Candidate :: Ref ( _) => false ,
124
121
Candidate :: Argument { .. } | Candidate :: InlineAsm { .. } => true ,
125
122
}
126
123
}
127
124
128
125
fn source_info ( & self , body : & Body < ' _ > ) -> SourceInfo {
129
126
match self {
130
- Candidate :: Ref ( location) | Candidate :: Repeat ( location ) => * body. source_info ( * location) ,
127
+ Candidate :: Ref ( location) => * body. source_info ( * location) ,
131
128
Candidate :: Argument { bb, .. } | Candidate :: InlineAsm { bb, .. } => {
132
129
* body. source_info ( body. terminator_loc ( * bb) )
133
130
}
@@ -213,11 +210,6 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
213
210
Rvalue :: Ref ( ..) => {
214
211
self . candidates . push ( Candidate :: Ref ( location) ) ;
215
212
}
216
- Rvalue :: Repeat ( ..) if self . ccx . tcx . features ( ) . const_in_array_repeat_expressions => {
217
- // FIXME(#49147) only promote the element when it isn't `Copy`
218
- // (so that code that can copy it at runtime is unaffected).
219
- self . candidates . push ( Candidate :: Repeat ( location) ) ;
220
- }
221
213
_ => { }
222
214
}
223
215
}
@@ -334,21 +326,6 @@ impl<'tcx> Validator<'_, 'tcx> {
334
326
_ => bug ! ( ) ,
335
327
}
336
328
}
337
- Candidate :: Repeat ( loc) => {
338
- assert ! ( !self . explicit) ;
339
-
340
- let statement = & self . body [ loc. block ] . statements [ loc. statement_index ] ;
341
- match & statement. kind {
342
- StatementKind :: Assign ( box ( _, Rvalue :: Repeat ( ref operand, _) ) ) => {
343
- if !self . tcx . features ( ) . const_in_array_repeat_expressions {
344
- return Err ( Unpromotable ) ;
345
- }
346
-
347
- self . validate_operand ( operand)
348
- }
349
- _ => bug ! ( ) ,
350
- }
351
- }
352
329
Candidate :: Argument { bb, index } => {
353
330
assert ! ( self . explicit) ;
354
331
@@ -1090,18 +1067,6 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
1090
1067
_ => bug ! ( ) ,
1091
1068
}
1092
1069
}
1093
- Candidate :: Repeat ( loc) => {
1094
- let statement = & mut blocks[ loc. block ] . statements [ loc. statement_index ] ;
1095
- match statement. kind {
1096
- StatementKind :: Assign ( box ( _, Rvalue :: Repeat ( ref mut operand, _) ) ) => {
1097
- let ty = operand. ty ( local_decls, self . tcx ) ;
1098
- let span = statement. source_info . span ;
1099
-
1100
- Rvalue :: Use ( mem:: replace ( operand, promoted_operand ( ty, span) ) )
1101
- }
1102
- _ => bug ! ( ) ,
1103
- }
1104
- }
1105
1070
Candidate :: Argument { bb, index } => {
1106
1071
let terminator = blocks[ bb] . terminator_mut ( ) ;
1107
1072
match terminator. kind {
@@ -1182,8 +1147,7 @@ pub fn promote_candidates<'tcx>(
1182
1147
let mut extra_statements = vec ! [ ] ;
1183
1148
for candidate in candidates. into_iter ( ) . rev ( ) {
1184
1149
match candidate {
1185
- Candidate :: Repeat ( Location { block, statement_index } )
1186
- | Candidate :: Ref ( Location { block, statement_index } ) => {
1150
+ Candidate :: Ref ( Location { block, statement_index } ) => {
1187
1151
if let StatementKind :: Assign ( box ( place, _) ) =
1188
1152
& body[ block] . statements [ statement_index] . kind
1189
1153
{
@@ -1267,27 +1231,3 @@ pub fn promote_candidates<'tcx>(
1267
1231
1268
1232
promotions
1269
1233
}
1270
-
1271
- /// This function returns `true` if the `const_in_array_repeat_expressions` feature attribute should
1272
- /// be suggested. This function is probably quite expensive, it shouldn't be run in the happy path.
1273
- /// Feature attribute should be suggested if `operand` can be promoted and the feature is not
1274
- /// enabled.
1275
- crate fn should_suggest_const_in_array_repeat_expressions_attribute < ' tcx > (
1276
- ccx : & ConstCx < ' _ , ' tcx > ,
1277
- operand : & Operand < ' tcx > ,
1278
- ) -> bool {
1279
- let mut rpo = traversal:: reverse_postorder ( & ccx. body ) ;
1280
- let ( temps, _) = collect_temps_and_candidates ( & ccx, & mut rpo) ;
1281
- let validator = Validator { ccx, temps : & temps, explicit : false } ;
1282
-
1283
- let should_promote = validator. validate_operand ( operand) . is_ok ( ) ;
1284
- let feature_flag = validator. ccx . tcx . features ( ) . const_in_array_repeat_expressions ;
1285
- debug ! (
1286
- "should_suggest_const_in_array_repeat_expressions_flag: def_id={:?} \
1287
- should_promote={:?} feature_flag={:?}",
1288
- validator. ccx. def_id( ) ,
1289
- should_promote,
1290
- feature_flag
1291
- ) ;
1292
- should_promote && !feature_flag
1293
- }
0 commit comments