@@ -436,8 +436,7 @@ fn use_verbose<'tcx>(ty: Ty<'tcx>, fn_def: bool) -> bool {
436
436
}
437
437
438
438
impl < ' tcx > Visitor < ' tcx > for ExtraComments < ' tcx > {
439
- fn visit_constant ( & mut self , constant : & Constant < ' tcx > , location : Location ) {
440
- self . super_constant ( constant, location) ;
439
+ fn visit_constant ( & mut self , constant : & Constant < ' tcx > , _location : Location ) {
441
440
let Constant { span, user_ty, literal } = constant;
442
441
if use_verbose ( literal. ty ( ) , true ) {
443
442
self . push ( "mir::Constant" ) ;
@@ -448,38 +447,30 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
448
447
if let Some ( user_ty) = user_ty {
449
448
self . push ( & format ! ( "+ user_ty: {:?}" , user_ty) ) ;
450
449
}
451
- match literal {
452
- ConstantKind :: Ty ( literal) => self . push ( & format ! ( "+ literal: {:?}" , literal) ) ,
453
- ConstantKind :: Val ( val, ty) => {
454
- // To keep the diffs small, we render this almost like we render ty::Const
455
- self . push ( & format ! ( "+ literal: Const {{ ty: {}, val: Value({:?}) }}" , ty, val) )
456
- }
457
- }
458
- }
459
- }
460
450
461
- fn visit_const ( & mut self , constant : ty :: Const < ' tcx > , _ : Location ) {
462
- self . super_const ( constant ) ;
463
- let ty = constant . ty ( ) ;
464
- let val = constant . val ( ) ;
465
- if use_verbose ( ty , false ) {
466
- self . push ( "ty::Const" ) ;
467
- self . push ( & format ! ( "+ ty: {:?}" , ty ) ) ;
468
- let val = match val {
469
- ty :: ConstKind :: Param ( p ) => format ! ( "Param({})" , p ) ,
470
- ty:: ConstKind :: Infer ( infer ) => format ! ( "Infer ({:?})" , infer ) ,
471
- ty:: ConstKind :: Bound ( idx , var ) => format ! ( "Bound({:?}, {:?})" , idx , var ) ,
472
- ty :: ConstKind :: Placeholder ( ph ) => format ! ( "PlaceHolder({:?})" , ph ) ,
473
- ty:: ConstKind :: Unevaluated ( uv ) => format ! (
474
- "Unevaluated({}, {:?}, {:?})" ,
475
- self . tcx . def_path_str ( uv . def . did ) ,
476
- uv . substs ,
477
- uv . promoted ,
478
- ) ,
479
- ty:: ConstKind :: Value ( val ) => format ! ( "Value({:?})" , val ) ,
480
- ty :: ConstKind :: Error ( _) => "Error" . to_string ( ) ,
451
+ let val = match literal {
452
+ ConstantKind :: Ty ( ct ) => match ct . val ( ) {
453
+ ty :: ConstKind :: Param ( p ) => format ! ( "Param({})" , p ) ,
454
+ ty :: ConstKind :: Unevaluated ( uv ) => format ! (
455
+ "Unevaluated({}, {:?}, {:?})" ,
456
+ self . tcx . def_path_str ( uv . def . did ) ,
457
+ uv . substs ,
458
+ uv . promoted ,
459
+ ) ,
460
+ ty:: ConstKind :: Value ( val ) => format ! ( "Value ({:?})" , val ) ,
461
+ ty:: ConstKind :: Error ( _ ) => "Error" . to_string ( ) ,
462
+ // These variants shouldn't exist in the MIR.
463
+ ty:: ConstKind :: Placeholder ( _ )
464
+ | ty :: ConstKind :: Infer ( _ )
465
+ | ty :: ConstKind :: Bound ( .. ) => bug ! ( "unexpected MIR constant: {:?}" , literal ) ,
466
+ } ,
467
+ // To keep the diffs small, we render this like we render `ty::Const::Value`.
468
+ //
469
+ // This changes once ` ty::Const ::Value` is represented using valtrees.
470
+ ConstantKind :: Val ( val , _) => format ! ( "Value({:?})" , val ) ,
481
471
} ;
482
- self . push ( & format ! ( "+ val: {}" , val) ) ;
472
+
473
+ self . push ( & format ! ( "+ literal: Const {{ ty: {}, val: {} }}" , literal. ty( ) , val) ) ;
483
474
}
484
475
}
485
476
0 commit comments