@@ -250,7 +250,7 @@ impl<'tcx> Const<'tcx> {
250250 // Dont use the outer ty as on invalid code we can wind up with them not being the same.
251251 // this then results in allowing const eval to add `1_i64 + 1_usize` in cases where the mir
252252 // was originally `({N: usize} + 1_usize)` under `generic_const_exprs`.
253- ty:: ConstKind :: Value ( ty , _ ) => ty,
253+ ty:: ConstKind :: Value ( cv ) => cv . ty ,
254254 _ => * ty,
255255 }
256256 }
@@ -264,7 +264,7 @@ impl<'tcx> Const<'tcx> {
264264 pub fn is_required_const ( & self ) -> bool {
265265 match self {
266266 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
268268 _ => true ,
269269 } ,
270270 Const :: Val ( ..) => false , // already a value, cannot error
@@ -276,11 +276,11 @@ impl<'tcx> Const<'tcx> {
276276 pub fn try_to_scalar ( self ) -> Option < Scalar > {
277277 match self {
278278 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 ( ) => {
280280 // A valtree of a type where leaves directly represent the scalar const value.
281281 // Just checking whether it is a leaf is insufficient as e.g. references are leafs
282282 // 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 ( ) )
284284 }
285285 _ => None ,
286286 } ,
@@ -295,9 +295,7 @@ impl<'tcx> Const<'tcx> {
295295 match self {
296296 Const :: Val ( ConstValue :: Scalar ( Scalar :: Int ( x) ) , _) => Some ( x) ,
297297 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 ( ) ) ,
301299 _ => None ,
302300 } ,
303301 _ => None ,
@@ -328,7 +326,7 @@ impl<'tcx> Const<'tcx> {
328326 }
329327
330328 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 ) ) ,
332330 ConstKind :: Expr ( _) => {
333331 bug ! ( "Normalization of `ty::ConstKind::Expr` is unimplemented" )
334332 }
@@ -353,13 +351,13 @@ impl<'tcx> Const<'tcx> {
353351 typing_env : ty:: TypingEnv < ' tcx > ,
354352 ) -> Option < Scalar > {
355353 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 ( )
358356 {
359357 // Avoid the `valtree_to_const_val` query. Can only be done on primitive types that
360358 // are valtree leaves, and *not* on references. (References should return the
361359 // pointer here, which valtrees don't represent.)
362- Some ( val . unwrap_leaf ( ) . into ( ) )
360+ Some ( cv . valtree . unwrap_leaf ( ) . into ( ) )
363361 } else {
364362 self . eval ( tcx, typing_env, DUMMY_SP ) . ok ( ) ?. try_to_scalar ( )
365363 }
@@ -473,7 +471,7 @@ impl<'tcx> Const<'tcx> {
473471 // A valtree may be a reference. Valtree references correspond to a
474472 // different allocation each time they are evaluated. Valtrees for primitive
475473 // types are fine though.
476- ty:: ConstKind :: Value ( ty , _ ) => ty. is_primitive ( ) ,
474+ ty:: ConstKind :: Value ( cv ) => cv . ty . is_primitive ( ) ,
477475 ty:: ConstKind :: Unevaluated ( ..) | ty:: ConstKind :: Expr ( ..) => false ,
478476 // This can happen if evaluation of a constant failed. The result does not matter
479477 // much since compilation is doomed.
0 commit comments