@@ -86,11 +86,12 @@ use std::mem;
86
86
use interpret:: ErrorHandled ;
87
87
use rustc_data_structures:: fx:: FxHashMap ;
88
88
use rustc_hir:: HirId ;
89
+ use rustc_hir:: def_id:: DefId ;
89
90
use rustc_index:: { IndexSlice , IndexVec } ;
90
91
use rustc_middle:: middle:: region;
91
92
use rustc_middle:: mir:: { self , * } ;
92
93
use 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 } ;
94
95
use rustc_middle:: { bug, span_bug, ty} ;
95
96
use rustc_pattern_analysis:: rustc:: RustcPatCtxt ;
96
97
use rustc_session:: lint:: Level ;
@@ -854,39 +855,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
854
855
pub ( crate ) fn break_const_continuable_scope (
855
856
& mut self ,
856
857
mut block : BasicBlock ,
857
- value : ExprId ,
858
+ did : DefId ,
859
+ args : GenericArgsRef < ' tcx > ,
860
+ ty : Ty < ' tcx > ,
858
861
scope : region:: Scope ,
859
862
source_info : SourceInfo ,
860
863
) -> BlockAnd < ( ) > {
861
864
let span = source_info. span ;
862
865
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_ } ;
890
869
891
870
let break_index = self
892
871
. scopes
0 commit comments