@@ -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 ;
@@ -814,39 +815,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
814815 pub ( crate ) fn break_const_continuable_scope (
815816 & mut self ,
816817 mut block : BasicBlock ,
817- value : ExprId ,
818+ did : DefId ,
819+ args : GenericArgsRef < ' tcx > ,
820+ ty : Ty < ' tcx > ,
818821 scope : region:: Scope ,
819822 source_info : SourceInfo ,
820823 ) -> BlockAnd < ( ) > {
821824 let span = source_info. span ;
822825
823- // A break can only break out of a scope, so the value should be a scope.
824- let rustc_middle:: thir:: ExprKind :: Scope { value, .. } = self . thir [ value] . kind else {
825- span_bug ! ( span, "break value must be a scope" )
826- } ;
827-
828- let constant = match & self . thir [ value] . kind {
829- ExprKind :: Adt ( box AdtExpr { variant_index, fields, base, .. } ) => {
830- assert ! ( matches!( base, AdtExprBase :: None ) ) ;
831- assert ! ( fields. is_empty( ) ) ;
832- ConstOperand {
833- span : self . thir [ value] . span ,
834- user_ty : None ,
835- const_ : Const :: Ty (
836- self . thir [ value] . ty ,
837- ty:: Const :: new_value (
838- self . tcx ,
839- ValTree :: from_branches (
840- self . tcx ,
841- [ ValTree :: from_scalar_int ( self . tcx , variant_index. as_u32 ( ) . into ( ) ) ] ,
842- ) ,
843- self . thir [ value] . ty ,
844- ) ,
845- ) ,
846- }
847- }
848- _ => self . as_constant ( & self . thir [ value] ) ,
849- } ;
826+ let uneval = UnevaluatedConst :: new ( did, args) ;
827+ let const_ = Const :: Unevaluated ( uneval, ty) ;
828+ let constant = ConstOperand { user_ty : None , span, const_ } ;
850829
851830 let break_index = self
852831 . scopes
0 commit comments