@@ -258,7 +258,7 @@ trait Qualif {
258
258
if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
259
259
Self :: in_any_value_of_ty ( cx, constant. literal . ty ) . unwrap_or ( false )
260
260
} else {
261
- let ( bits, _ ) = cx. tcx . at ( constant. span ) . mir_const_qualif ( def_id) ;
261
+ let bits = cx. tcx . at ( constant. span ) . mir_const_qualif ( def_id) ;
262
262
263
263
let qualif = PerQualif :: decode_from_bits ( bits) . 0 [ Self :: IDX ] ;
264
264
@@ -682,7 +682,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
682
682
}
683
683
684
684
/// Check a whole const, static initializer or const fn.
685
- fn check_const ( & mut self ) -> ( u8 , & ' tcx BitSet < Local > ) {
685
+ fn check_const ( & mut self ) -> u8 {
686
686
use crate :: transform:: check_consts as new_checker;
687
687
688
688
debug ! ( "const-checking {} {:?}" , self . mode, self . def_id) ;
@@ -704,7 +704,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
704
704
705
705
let mut seen_blocks = BitSet :: new_empty ( body. basic_blocks ( ) . len ( ) ) ;
706
706
let mut bb = START_BLOCK ;
707
- let mut has_controlflow_error = false ;
708
707
loop {
709
708
seen_blocks. insert ( bb. index ( ) ) ;
710
709
@@ -745,7 +744,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
745
744
bb = target;
746
745
}
747
746
_ => {
748
- has_controlflow_error = true ;
749
747
self . not_const ( ops:: Loop ) ;
750
748
validator. check_op ( ops:: Loop ) ;
751
749
break ;
@@ -772,51 +770,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
772
770
}
773
771
}
774
772
775
- // Collect all the temps we need to promote.
776
- let mut promoted_temps = BitSet :: new_empty ( self . temp_promotion_state . len ( ) ) ;
777
-
778
- // HACK: if parts of the control-flow graph were skipped due to an error, don't try to
779
- // promote anything, since that can cause errors in a `const` if e.g. rvalue static
780
- // promotion is attempted within a loop body.
781
- let unleash_miri = self . tcx . sess . opts . debugging_opts . unleash_the_miri_inside_of_you ;
782
- let promotion_candidates = if has_controlflow_error && !unleash_miri {
783
- self . tcx . sess . delay_span_bug (
784
- body. span ,
785
- "check_const: expected control-flow error(s)" ,
786
- ) ;
787
-
788
- vec ! [ ]
789
- } else {
790
- promote_consts:: validate_candidates (
791
- self . tcx ,
792
- self . body ,
793
- self . def_id ,
794
- & self . temp_promotion_state ,
795
- & self . unchecked_promotion_candidates ,
796
- )
797
- } ;
798
-
799
- debug ! ( "qualify_const: promotion_candidates={:?}" , promotion_candidates) ;
800
- for candidate in promotion_candidates {
801
- match candidate {
802
- Candidate :: Ref ( Location { block : bb, statement_index : stmt_idx } ) => {
803
- if let StatementKind :: Assign ( box( _, Rvalue :: Ref ( _, _, place) ) )
804
- = & self . body [ bb] . statements [ stmt_idx] . kind
805
- {
806
- if let PlaceBase :: Local ( local) = place. base {
807
- promoted_temps. insert ( local) ;
808
- }
809
- }
810
- }
811
-
812
- // Only rvalue-static promotion requires extending the lifetime of the promoted
813
- // local.
814
- Candidate :: Argument { .. } | Candidate :: Repeat ( _) => { }
815
- }
816
- }
817
-
818
- let qualifs = self . qualifs_in_local ( RETURN_PLACE ) ;
819
- ( qualifs. encode_to_bits ( ) , self . tcx . arena . alloc ( promoted_temps) )
773
+ self . qualifs_in_local ( RETURN_PLACE ) . encode_to_bits ( )
820
774
}
821
775
}
822
776
@@ -1346,7 +1300,7 @@ pub fn provide(providers: &mut Providers<'_>) {
1346
1300
// in `promote_consts`, see the comment in `validate_operand`.
1347
1301
pub ( super ) const QUALIF_ERROR_BIT : u8 = 1 << 2 ;
1348
1302
1349
- fn mir_const_qualif ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> ( u8 , & BitSet < Local > ) {
1303
+ fn mir_const_qualif ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> u8 {
1350
1304
// N.B., this `borrow()` is guaranteed to be valid (i.e., the value
1351
1305
// cannot yet be stolen), because `mir_validated()`, which steals
1352
1306
// from `mir_const(), forces this query to execute before
@@ -1355,7 +1309,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> (u8, &BitSet<Local>) {
1355
1309
1356
1310
if body. return_ty ( ) . references_error ( ) {
1357
1311
tcx. sess . delay_span_bug ( body. span , "mir_const_qualif: MIR had errors" ) ;
1358
- return ( QUALIF_ERROR_BIT , tcx . arena . alloc ( BitSet :: new_empty ( 0 ) ) ) ;
1312
+ return QUALIF_ERROR_BIT ;
1359
1313
}
1360
1314
1361
1315
Checker :: new ( tcx, def_id, body, Mode :: Const ) . check_const ( )
@@ -1436,11 +1390,11 @@ impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants<'tcx> {
1436
1390
} else {
1437
1391
check_short_circuiting_in_const_local ( tcx, body, mode) ;
1438
1392
1439
- let promoted_temps = match mode {
1440
- Mode :: Const => tcx. mir_const_qualif ( def_id) . 1 ,
1441
- _ => Checker :: new ( tcx, def_id, body, mode) . check_const ( ) . 1 ,
1393
+ match mode {
1394
+ Mode :: Const => tcx. mir_const_qualif ( def_id) ,
1395
+ _ => Checker :: new ( tcx, def_id, body, mode) . check_const ( ) ,
1442
1396
} ;
1443
- remove_drop_and_storage_dead_on_promoted_locals ( body, promoted_temps ) ;
1397
+ remove_drop_and_storage_dead_on_promoted_locals ( body, unimplemented ! ( ) ) ;
1444
1398
}
1445
1399
1446
1400
if mode == Mode :: Static && !tcx. has_attr ( def_id, sym:: thread_local) {
0 commit comments