@@ -102,9 +102,6 @@ pub enum Candidate {
102102 /// Borrow of a constant temporary, candidate for lifetime extension.
103103 Ref ( Location ) ,
104104
105- /// Promotion of the `x` in `[x; 32]`.
106- Repeat ( Location ) ,
107-
108105 /// Currently applied to function calls where the callee has the unstable
109106 /// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle
110107 /// intrinsic. The intrinsic requires the arguments are indeed constant and
@@ -120,14 +117,14 @@ impl Candidate {
120117 /// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
121118 fn forces_explicit_promotion ( & self ) -> bool {
122119 match self {
123- Candidate :: Ref ( _) | Candidate :: Repeat ( _ ) => false ,
120+ Candidate :: Ref ( _) => false ,
124121 Candidate :: Argument { .. } | Candidate :: InlineAsm { .. } => true ,
125122 }
126123 }
127124
128125 fn source_info ( & self , body : & Body < ' _ > ) -> SourceInfo {
129126 match self {
130- Candidate :: Ref ( location) | Candidate :: Repeat ( location ) => * body. source_info ( * location) ,
127+ Candidate :: Ref ( location) => * body. source_info ( * location) ,
131128 Candidate :: Argument { bb, .. } | Candidate :: InlineAsm { bb, .. } => {
132129 * body. source_info ( body. terminator_loc ( * bb) )
133130 }
@@ -213,11 +210,6 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
213210 Rvalue :: Ref ( ..) => {
214211 self . candidates . push ( Candidate :: Ref ( location) ) ;
215212 }
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- }
221213 _ => { }
222214 }
223215 }
@@ -334,21 +326,6 @@ impl<'tcx> Validator<'_, 'tcx> {
334326 _ => bug ! ( ) ,
335327 }
336328 }
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- }
352329 Candidate :: Argument { bb, index } => {
353330 assert ! ( self . explicit) ;
354331
@@ -1090,18 +1067,6 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
10901067 _ => bug ! ( ) ,
10911068 }
10921069 }
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- }
11051070 Candidate :: Argument { bb, index } => {
11061071 let terminator = blocks[ bb] . terminator_mut ( ) ;
11071072 match terminator. kind {
@@ -1182,8 +1147,7 @@ pub fn promote_candidates<'tcx>(
11821147 let mut extra_statements = vec ! [ ] ;
11831148 for candidate in candidates. into_iter ( ) . rev ( ) {
11841149 match candidate {
1185- Candidate :: Repeat ( Location { block, statement_index } )
1186- | Candidate :: Ref ( Location { block, statement_index } ) => {
1150+ Candidate :: Ref ( Location { block, statement_index } ) => {
11871151 if let StatementKind :: Assign ( box ( place, _) ) =
11881152 & body[ block] . statements [ statement_index] . kind
11891153 {
@@ -1267,27 +1231,3 @@ pub fn promote_candidates<'tcx>(
12671231
12681232 promotions
12691233}
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