@@ -1345,56 +1345,34 @@ impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants<'tcx> {
13451345        let  mode = determine_mode ( tcx,  hir_id,  def_id) ; 
13461346
13471347        debug ! ( "run_pass: mode={:?}" ,  mode) ; 
1348-         if  let  Mode :: NonConstFn  | Mode :: ConstFn  = mode { 
1348+         if  let  Mode :: NonConstFn  = mode { 
1349+             // No need to const-check a non-const `fn` now that we don't do promotion here. 
1350+             return ; 
1351+         }  else  if  let  Mode :: ConstFn  = mode { 
13491352            let  mut  checker = Checker :: new ( tcx,  def_id,  body,  mode) ; 
1350-             if  let  Mode :: ConstFn  = mode { 
1351-                 let  use_min_const_fn_checks =
1352-                     !tcx. sess . opts . debugging_opts . unleash_the_miri_inside_of_you  &&
1353-                     tcx. is_min_const_fn ( def_id) ; 
1354-                 if  use_min_const_fn_checks { 
1355-                     // Enforce `min_const_fn` for stable `const fn`s. 
1356-                     use  super :: qualify_min_const_fn:: is_min_const_fn; 
1357-                     if  let  Err ( ( span,  err) )  = is_min_const_fn ( tcx,  def_id,  body)  { 
1358-                         error_min_const_fn_violation ( tcx,  span,  err) ; 
1359-                         return ; 
1360-                     } 
1361- 
1362-                     // `check_const` should not produce any errors, but better safe than sorry 
1363-                     // FIXME(#53819) 
1364-                     // NOTE(eddyb) `check_const` is actually needed for promotion inside 
1365-                     // `min_const_fn` functions. 
1366-                 } 
1367- 
1368-                 // Enforce a constant-like CFG for `const fn`. 
1369-                 checker. check_const ( ) ; 
1370-             }  else  { 
1371-                 while  let  Some ( ( bb,  data) )  = checker. rpo . next ( )  { 
1372-                     checker. visit_basic_block_data ( bb,  data) ; 
1353+             let  use_min_const_fn_checks =
1354+                 !tcx. sess . opts . debugging_opts . unleash_the_miri_inside_of_you  &&
1355+                 tcx. is_min_const_fn ( def_id) ; 
1356+             if  use_min_const_fn_checks { 
1357+                 // Enforce `min_const_fn` for stable `const fn`s. 
1358+                 use  super :: qualify_min_const_fn:: is_min_const_fn; 
1359+                 if  let  Err ( ( span,  err) )  = is_min_const_fn ( tcx,  def_id,  body)  { 
1360+                     error_min_const_fn_violation ( tcx,  span,  err) ; 
1361+                     return ; 
13731362                } 
13741363            } 
13751364
1376-             // Promote only the promotable candidates. 
1377-             let  temps = checker. temp_promotion_state ; 
1378-             let  candidates = promote_consts:: validate_candidates ( 
1379-                 tcx, 
1380-                 body, 
1381-                 def_id, 
1382-                 & temps, 
1383-                 & checker. unchecked_promotion_candidates , 
1384-             ) ; 
1385- 
1386-             // Do the actual promotion, now that we know what's viable. 
1387-             self . promoted . set ( 
1388-                 promote_consts:: promote_candidates ( def_id,  body,  tcx,  temps,  candidates) 
1389-             ) ; 
1365+             // `check_const` should not produce any errors, but better safe than sorry 
1366+             // FIXME(#53819) 
1367+             // Enforce a constant-like CFG for `const fn`. 
1368+             checker. check_const ( ) ; 
13901369        }  else  { 
13911370            check_short_circuiting_in_const_local ( tcx,  body,  mode) ; 
13921371
13931372            match  mode { 
13941373                Mode :: Const  => tcx. mir_const_qualif ( def_id) , 
13951374                _ => Checker :: new ( tcx,  def_id,  body,  mode) . check_const ( ) , 
13961375            } ; 
1397-             remove_drop_and_storage_dead_on_promoted_locals ( body,  unimplemented ! ( ) ) ; 
13981376        } 
13991377
14001378        if  mode == Mode :: Static  && !tcx. has_attr ( def_id,  sym:: thread_local)  { 
0 commit comments