@@ -258,7 +258,7 @@ trait Qualif {
258258 if cx. tcx . trait_of_item ( def_id) . is_some ( ) {
259259 Self :: in_any_value_of_ty ( cx, constant. literal . ty ) . unwrap_or ( false )
260260 } 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) ;
262262
263263 let qualif = PerQualif :: decode_from_bits ( bits) . 0 [ Self :: IDX ] ;
264264
@@ -682,7 +682,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
682682 }
683683
684684 /// 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 {
686686 use crate :: transform:: check_consts as new_checker;
687687
688688 debug ! ( "const-checking {} {:?}" , self . mode, self . def_id) ;
@@ -704,7 +704,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
704704
705705 let mut seen_blocks = BitSet :: new_empty ( body. basic_blocks ( ) . len ( ) ) ;
706706 let mut bb = START_BLOCK ;
707- let mut has_controlflow_error = false ;
708707 loop {
709708 seen_blocks. insert ( bb. index ( ) ) ;
710709
@@ -745,7 +744,6 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
745744 bb = target;
746745 }
747746 _ => {
748- has_controlflow_error = true ;
749747 self . not_const ( ops:: Loop ) ;
750748 validator. check_op ( ops:: Loop ) ;
751749 break ;
@@ -772,51 +770,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
772770 }
773771 }
774772
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 ( )
820774 }
821775}
822776
@@ -1346,7 +1300,7 @@ pub fn provide(providers: &mut Providers<'_>) {
13461300// in `promote_consts`, see the comment in `validate_operand`.
13471301pub ( super ) const QUALIF_ERROR_BIT : u8 = 1 << 2 ;
13481302
1349- fn mir_const_qualif ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> ( u8 , & BitSet < Local > ) {
1303+ fn mir_const_qualif ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> u8 {
13501304 // N.B., this `borrow()` is guaranteed to be valid (i.e., the value
13511305 // cannot yet be stolen), because `mir_validated()`, which steals
13521306 // 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>) {
13551309
13561310 if body. return_ty ( ) . references_error ( ) {
13571311 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 ;
13591313 }
13601314
13611315 Checker :: new ( tcx, def_id, body, Mode :: Const ) . check_const ( )
@@ -1436,11 +1390,11 @@ impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants<'tcx> {
14361390 } else {
14371391 check_short_circuiting_in_const_local ( tcx, body, mode) ;
14381392
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 ( ) ,
14421396 } ;
1443- remove_drop_and_storage_dead_on_promoted_locals ( body, promoted_temps ) ;
1397+ remove_drop_and_storage_dead_on_promoted_locals ( body, unimplemented ! ( ) ) ;
14441398 }
14451399
14461400 if mode == Mode :: Static && !tcx. has_attr ( def_id, sym:: thread_local) {
0 commit comments