@@ -250,7 +250,7 @@ impl<'tcx> Const<'tcx> {
250
250
// Dont use the outer ty as on invalid code we can wind up with them not being the same.
251
251
// this then results in allowing const eval to add `1_i64 + 1_usize` in cases where the mir
252
252
// was originally `({N: usize} + 1_usize)` under `generic_const_exprs`.
253
- ty:: ConstKind :: Value ( ty , _ ) => ty,
253
+ ty:: ConstKind :: Value ( cv ) => cv . ty ,
254
254
_ => * ty,
255
255
}
256
256
}
@@ -264,7 +264,7 @@ impl<'tcx> Const<'tcx> {
264
264
pub fn is_required_const ( & self ) -> bool {
265
265
match self {
266
266
Const :: Ty ( _, c) => match c. kind ( ) {
267
- ty:: ConstKind :: Value ( _, _ ) => false , // already a value, cannot error
267
+ ty:: ConstKind :: Value ( _) => false , // already a value, cannot error
268
268
_ => true ,
269
269
} ,
270
270
Const :: Val ( ..) => false , // already a value, cannot error
@@ -276,11 +276,11 @@ impl<'tcx> Const<'tcx> {
276
276
pub fn try_to_scalar ( self ) -> Option < Scalar > {
277
277
match self {
278
278
Const :: Ty ( _, c) => match c. kind ( ) {
279
- ty:: ConstKind :: Value ( ty , valtree ) if ty. is_primitive ( ) => {
279
+ ty:: ConstKind :: Value ( cv ) if cv . ty . is_primitive ( ) => {
280
280
// A valtree of a type where leaves directly represent the scalar const value.
281
281
// Just checking whether it is a leaf is insufficient as e.g. references are leafs
282
282
// but the leaf value is the value they point to, not the reference itself!
283
- Some ( valtree. unwrap_leaf ( ) . into ( ) )
283
+ Some ( cv . valtree . unwrap_leaf ( ) . into ( ) )
284
284
}
285
285
_ => None ,
286
286
} ,
@@ -295,9 +295,7 @@ impl<'tcx> Const<'tcx> {
295
295
match self {
296
296
Const :: Val ( ConstValue :: Scalar ( Scalar :: Int ( x) ) , _) => Some ( x) ,
297
297
Const :: Ty ( _, c) => match c. kind ( ) {
298
- ty:: ConstKind :: Value ( ty, valtree) if ty. is_primitive ( ) => {
299
- Some ( valtree. unwrap_leaf ( ) )
300
- }
298
+ ty:: ConstKind :: Value ( cv) if cv. ty . is_primitive ( ) => Some ( cv. valtree . unwrap_leaf ( ) ) ,
301
299
_ => None ,
302
300
} ,
303
301
_ => None ,
@@ -328,7 +326,7 @@ impl<'tcx> Const<'tcx> {
328
326
}
329
327
330
328
match c. kind ( ) {
331
- ConstKind :: Value ( ty , val ) => Ok ( tcx. valtree_to_const_val ( ( ty , val ) ) ) ,
329
+ ConstKind :: Value ( cv ) => Ok ( tcx. valtree_to_const_val ( cv ) ) ,
332
330
ConstKind :: Expr ( _) => {
333
331
bug ! ( "Normalization of `ty::ConstKind::Expr` is unimplemented" )
334
332
}
@@ -353,13 +351,13 @@ impl<'tcx> Const<'tcx> {
353
351
typing_env : ty:: TypingEnv < ' tcx > ,
354
352
) -> Option < Scalar > {
355
353
if let Const :: Ty ( _, c) = self
356
- && let ty:: ConstKind :: Value ( ty , val ) = c. kind ( )
357
- && ty. is_primitive ( )
354
+ && let ty:: ConstKind :: Value ( cv ) = c. kind ( )
355
+ && cv . ty . is_primitive ( )
358
356
{
359
357
// Avoid the `valtree_to_const_val` query. Can only be done on primitive types that
360
358
// are valtree leaves, and *not* on references. (References should return the
361
359
// pointer here, which valtrees don't represent.)
362
- Some ( val . unwrap_leaf ( ) . into ( ) )
360
+ Some ( cv . valtree . unwrap_leaf ( ) . into ( ) )
363
361
} else {
364
362
self . eval ( tcx, typing_env, DUMMY_SP ) . ok ( ) ?. try_to_scalar ( )
365
363
}
@@ -473,7 +471,7 @@ impl<'tcx> Const<'tcx> {
473
471
// A valtree may be a reference. Valtree references correspond to a
474
472
// different allocation each time they are evaluated. Valtrees for primitive
475
473
// types are fine though.
476
- ty:: ConstKind :: Value ( ty , _ ) => ty. is_primitive ( ) ,
474
+ ty:: ConstKind :: Value ( cv ) => cv . ty . is_primitive ( ) ,
477
475
ty:: ConstKind :: Unevaluated ( ..) | ty:: ConstKind :: Expr ( ..) => false ,
478
476
// This can happen if evaluation of a constant failed. The result does not matter
479
477
// much since compilation is doomed.
0 commit comments