@@ -86,11 +86,12 @@ use std::mem;
8686use interpret:: ErrorHandled ;
8787use rustc_data_structures:: fx:: FxHashMap ;
8888use rustc_hir:: HirId ;
89+ use rustc_hir:: def_id:: DefId ;
8990use rustc_index:: { IndexSlice , IndexVec } ;
9091use rustc_middle:: middle:: region;
9192use rustc_middle:: mir:: { self , * } ;
9293use rustc_middle:: thir:: { AdtExpr , AdtExprBase , ArmId , ExprId , ExprKind , LintLevel } ;
93- use rustc_middle:: ty:: { Ty , TypeVisitableExt , ValTree } ;
94+ use rustc_middle:: ty:: { GenericArgsRef , Ty , TypeVisitableExt , ValTree } ;
9495use rustc_middle:: { bug, span_bug, ty} ;
9596use rustc_pattern_analysis:: rustc:: RustcPatCtxt ;
9697use rustc_session:: lint:: Level ;
@@ -854,39 +855,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
854855 pub ( crate ) fn break_const_continuable_scope (
855856 & mut self ,
856857 mut block : BasicBlock ,
857- value : ExprId ,
858+ did : DefId ,
859+ args : GenericArgsRef < ' tcx > ,
860+ ty : Ty < ' tcx > ,
858861 scope : region:: Scope ,
859862 source_info : SourceInfo ,
860863 ) -> BlockAnd < ( ) > {
861864 let span = source_info. span ;
862865
863- // A break can only break out of a scope, so the value should be a scope.
864- let rustc_middle:: thir:: ExprKind :: Scope { value, .. } = self . thir [ value] . kind else {
865- span_bug ! ( span, "break value must be a scope" )
866- } ;
867-
868- let constant = match & self . thir [ value] . kind {
869- ExprKind :: Adt ( box AdtExpr { variant_index, fields, base, .. } ) => {
870- assert ! ( matches!( base, AdtExprBase :: None ) ) ;
871- assert ! ( fields. is_empty( ) ) ;
872- ConstOperand {
873- span : self . thir [ value] . span ,
874- user_ty : None ,
875- const_ : Const :: Ty (
876- self . thir [ value] . ty ,
877- ty:: Const :: new_value (
878- self . tcx ,
879- ValTree :: from_branches (
880- self . tcx ,
881- [ ValTree :: from_scalar_int ( self . tcx , variant_index. as_u32 ( ) . into ( ) ) ] ,
882- ) ,
883- self . thir [ value] . ty ,
884- ) ,
885- ) ,
886- }
887- }
888- _ => self . as_constant ( & self . thir [ value] ) ,
889- } ;
866+ let uneval = UnevaluatedConst :: new ( did, args) ;
867+ let const_ = Const :: Unevaluated ( uneval, ty) ;
868+ let constant = ConstOperand { user_ty : None , span, const_ } ;
890869
891870 let break_index = self
892871 . scopes
0 commit comments