@@ -85,11 +85,12 @@ use std::mem;
85
85
86
86
use rustc_data_structures:: fx:: FxHashMap ;
87
87
use rustc_hir:: HirId ;
88
+ use rustc_hir:: def_id:: DefId ;
88
89
use rustc_index:: { IndexSlice , IndexVec } ;
89
90
use rustc_middle:: middle:: region;
90
91
use rustc_middle:: mir:: * ;
91
92
use rustc_middle:: thir:: { AdtExpr , AdtExprBase , ArmId , ExprId , ExprKind , LintLevel } ;
92
- use rustc_middle:: ty:: ValTree ;
93
+ use rustc_middle:: ty:: { GenericArgsRef , Ty , ValTree } ;
93
94
use rustc_middle:: { bug, span_bug, ty} ;
94
95
use rustc_pattern_analysis:: rustc:: RustcPatCtxt ;
95
96
use rustc_session:: lint:: Level ;
@@ -814,39 +815,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
814
815
pub ( crate ) fn break_const_continuable_scope (
815
816
& mut self ,
816
817
mut block : BasicBlock ,
817
- value : ExprId ,
818
+ did : DefId ,
819
+ args : GenericArgsRef < ' tcx > ,
820
+ ty : Ty < ' tcx > ,
818
821
scope : region:: Scope ,
819
822
source_info : SourceInfo ,
820
823
) -> BlockAnd < ( ) > {
821
824
let span = source_info. span ;
822
825
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_ } ;
850
829
851
830
let break_index = self
852
831
. scopes
0 commit comments