@@ -5,7 +5,7 @@ use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
55use rustc_middle:: thir:: visit;
66use rustc_middle:: thir:: visit:: Visitor ;
77use rustc_middle:: ty:: abstract_const:: CastKind ;
8- use rustc_middle:: ty:: { self , ConstKind , Expr , TyCtxt , TypeVisitable } ;
8+ use rustc_middle:: ty:: { self , Expr , TyCtxt , TypeVisitable } ;
99use rustc_middle:: { mir, thir} ;
1010use rustc_span:: Span ;
1111use rustc_target:: abi:: VariantIdx ;
@@ -32,10 +32,8 @@ pub(crate) fn destructure_const<'tcx>(
3232 let ( fields, variant) = match const_. ty ( ) . kind ( ) {
3333 ty:: Array ( inner_ty, _) | ty:: Slice ( inner_ty) => {
3434 // construct the consts for the elements of the array/slice
35- let field_consts = branches
36- . iter ( )
37- . map ( |b| tcx. mk_const ( ty:: ConstKind :: Value ( * b) , * inner_ty) )
38- . collect :: < Vec < _ > > ( ) ;
35+ let field_consts =
36+ branches. iter ( ) . map ( |b| tcx. mk_const ( * b, * inner_ty) ) . collect :: < Vec < _ > > ( ) ;
3937 debug ! ( ?field_consts) ;
4038
4139 ( field_consts, None )
@@ -53,7 +51,7 @@ pub(crate) fn destructure_const<'tcx>(
5351
5452 for ( field, field_valtree) in iter:: zip ( fields, branches) {
5553 let field_ty = field. ty ( tcx, substs) ;
56- let field_const = tcx. mk_const ( ty :: ConstKind :: Value ( * field_valtree) , field_ty) ;
54+ let field_const = tcx. mk_const ( * field_valtree, field_ty) ;
5755 field_consts. push ( field_const) ;
5856 }
5957 debug ! ( ?field_consts) ;
@@ -62,9 +60,7 @@ pub(crate) fn destructure_const<'tcx>(
6260 }
6361 ty:: Tuple ( elem_tys) => {
6462 let fields = iter:: zip ( * elem_tys, branches)
65- . map ( |( elem_ty, elem_valtree) | {
66- tcx. mk_const ( ty:: ConstKind :: Value ( * elem_valtree) , elem_ty)
67- } )
63+ . map ( |( elem_ty, elem_valtree) | tcx. mk_const ( * elem_valtree, elem_ty) )
6864 . collect :: < Vec < _ > > ( ) ;
6965
7066 ( fields, None )
@@ -137,9 +133,9 @@ fn recurse_build<'tcx>(
137133 }
138134 & ExprKind :: NamedConst { def_id, substs, user_ty : _ } => {
139135 let uneval = ty:: UnevaluatedConst :: new ( ty:: WithOptConstParam :: unknown ( def_id) , substs) ;
140- tcx. mk_const ( ty :: ConstKind :: Unevaluated ( uneval) , node. ty )
136+ tcx. mk_const ( uneval, node. ty )
141137 }
142- ExprKind :: ConstParam { param, .. } => tcx. mk_const ( ty :: ConstKind :: Param ( * param) , node. ty ) ,
138+ ExprKind :: ConstParam { param, .. } => tcx. mk_const ( * param, node. ty ) ,
143139
144140 ExprKind :: Call { fun, args, .. } => {
145141 let fun = recurse_build ( tcx, body, * fun, root_span) ?;
@@ -149,16 +145,16 @@ fn recurse_build<'tcx>(
149145 new_args. push ( recurse_build ( tcx, body, id, root_span) ?) ;
150146 }
151147 let new_args = tcx. mk_const_list ( new_args. iter ( ) ) ;
152- tcx. mk_const ( ConstKind :: Expr ( Expr :: FunctionCall ( fun, new_args) ) , node. ty )
148+ tcx. mk_const ( Expr :: FunctionCall ( fun, new_args) , node. ty )
153149 }
154150 & ExprKind :: Binary { op, lhs, rhs } if check_binop ( op) => {
155151 let lhs = recurse_build ( tcx, body, lhs, root_span) ?;
156152 let rhs = recurse_build ( tcx, body, rhs, root_span) ?;
157- tcx. mk_const ( ConstKind :: Expr ( Expr :: Binop ( op, lhs, rhs) ) , node. ty )
153+ tcx. mk_const ( Expr :: Binop ( op, lhs, rhs) , node. ty )
158154 }
159155 & ExprKind :: Unary { op, arg } if check_unop ( op) => {
160156 let arg = recurse_build ( tcx, body, arg, root_span) ?;
161- tcx. mk_const ( ConstKind :: Expr ( Expr :: UnOp ( op, arg) ) , node. ty )
157+ tcx. mk_const ( Expr :: UnOp ( op, arg) , node. ty )
162158 }
163159 // This is necessary so that the following compiles:
164160 //
@@ -179,11 +175,11 @@ fn recurse_build<'tcx>(
179175 // This is important so that `N as usize as usize` doesnt unify with `N as usize`. (untested)
180176 & ExprKind :: Use { source } => {
181177 let arg = recurse_build ( tcx, body, source, root_span) ?;
182- tcx. mk_const ( ConstKind :: Expr ( Expr :: Cast ( CastKind :: Use , arg, node. ty ) ) , node. ty )
178+ tcx. mk_const ( Expr :: Cast ( CastKind :: Use , arg, node. ty ) , node. ty )
183179 }
184180 & ExprKind :: Cast { source } => {
185181 let arg = recurse_build ( tcx, body, source, root_span) ?;
186- tcx. mk_const ( ConstKind :: Expr ( Expr :: Cast ( CastKind :: As , arg, node. ty ) ) , node. ty )
182+ tcx. mk_const ( Expr :: Cast ( CastKind :: As , arg, node. ty ) , node. ty )
187183 }
188184 ExprKind :: Borrow { arg, .. } => {
189185 let arg_node = & body. exprs [ * arg] ;
0 commit comments