@@ -17,9 +17,8 @@ use rustc_middle::mir::interpret::{
1717use rustc_middle:: mir:: visit:: Visitor ;
1818use rustc_middle:: mir:: MirSource ;
1919use rustc_middle:: mir:: * ;
20- use rustc_middle:: ty:: { self , TyCtxt , TypeFoldable , TypeVisitor } ;
20+ use rustc_middle:: ty:: { self , TyCtxt } ;
2121use rustc_target:: abi:: Size ;
22- use std:: ops:: ControlFlow ;
2322
2423const INDENT : & str = " " ;
2524/// Alignment for lining up comments following MIR statements
@@ -669,16 +668,27 @@ pub fn write_allocations<'tcx>(
669668 }
670669 }
671670 struct CollectAllocIds ( BTreeSet < AllocId > ) ;
672- impl < ' tcx > TypeVisitor < ' tcx > for CollectAllocIds {
673- fn visit_const ( & mut self , c : ty:: Const < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
671+
672+ impl < ' tcx > Visitor < ' tcx > for CollectAllocIds {
673+ fn visit_const ( & mut self , c : ty:: Const < ' tcx > , _loc : Location ) {
674674 if let ty:: ConstKind :: Value ( val) = c. val ( ) {
675675 self . 0 . extend ( alloc_ids_from_const ( val) ) ;
676676 }
677- c. super_visit_with ( self )
677+ }
678+
679+ fn visit_constant ( & mut self , c : & Constant < ' tcx > , loc : Location ) {
680+ match c. literal {
681+ ConstantKind :: Ty ( c) => self . visit_const ( c, loc) ,
682+ ConstantKind :: Val ( val, _) => {
683+ self . 0 . extend ( alloc_ids_from_const ( val) ) ;
684+ }
685+ }
678686 }
679687 }
688+
680689 let mut visitor = CollectAllocIds ( Default :: default ( ) ) ;
681- body. visit_with ( & mut visitor) ;
690+ visitor. visit_body ( body) ;
691+
682692 // `seen` contains all seen allocations, including the ones we have *not* printed yet.
683693 // The protocol is to first `insert` into `seen`, and only if that returns `true`
684694 // then push to `todo`.
0 commit comments