@@ -85,11 +85,12 @@ use std::mem;
8585
8686use rustc_data_structures:: fx:: FxHashMap ;
8787use rustc_hir:: HirId ;
88+ use rustc_hir:: def_id:: DefId ;
8889use rustc_index:: { IndexSlice , IndexVec } ;
8990use rustc_middle:: middle:: region;
9091use rustc_middle:: mir:: * ;
9192use rustc_middle:: thir:: { AdtExpr , AdtExprBase , ArmId , ExprId , ExprKind , LintLevel } ;
92- use rustc_middle:: ty:: ValTree ;
93+ use rustc_middle:: ty:: { GenericArgsRef , Ty , ValTree } ;
9394use rustc_middle:: { bug, span_bug, ty} ;
9495use rustc_pattern_analysis:: rustc:: RustcPatCtxt ;
9596use rustc_session:: lint:: Level ;
@@ -817,39 +818,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
817818 pub ( crate ) fn break_const_continuable_scope (
818819 & mut self ,
819820 mut block : BasicBlock ,
820- value : ExprId ,
821+ did : DefId ,
822+ args : GenericArgsRef < ' tcx > ,
823+ ty : Ty < ' tcx > ,
821824 scope : region:: Scope ,
822825 source_info : SourceInfo ,
823826 ) -> BlockAnd < ( ) > {
824827 let span = source_info. span ;
825828
826- // A break can only break out of a scope, so the value should be a scope.
827- let rustc_middle:: thir:: ExprKind :: Scope { value, .. } = self . thir [ value] . kind else {
828- span_bug ! ( span, "break value must be a scope" )
829- } ;
830-
831- let constant = match & self . thir [ value] . kind {
832- ExprKind :: Adt ( box AdtExpr { variant_index, fields, base, .. } ) => {
833- assert ! ( matches!( base, AdtExprBase :: None ) ) ;
834- assert ! ( fields. is_empty( ) ) ;
835- ConstOperand {
836- span : self . thir [ value] . span ,
837- user_ty : None ,
838- const_ : Const :: Ty (
839- self . thir [ value] . ty ,
840- ty:: Const :: new_value (
841- self . tcx ,
842- ValTree :: from_branches (
843- self . tcx ,
844- [ ValTree :: from_scalar_int ( self . tcx , variant_index. as_u32 ( ) . into ( ) ) ] ,
845- ) ,
846- self . thir [ value] . ty ,
847- ) ,
848- ) ,
849- }
850- }
851- _ => self . as_constant ( & self . thir [ value] ) ,
852- } ;
829+ let uneval = UnevaluatedConst :: new ( did, args) ;
830+ let const_ = Const :: Unevaluated ( uneval, ty) ;
831+ let constant = ConstOperand { user_ty : None , span, const_ } ;
853832
854833 let break_index = self
855834 . scopes
0 commit comments