@@ -17,9 +17,8 @@ use rustc_middle::mir::interpret::{
17
17
use rustc_middle:: mir:: visit:: Visitor ;
18
18
use rustc_middle:: mir:: MirSource ;
19
19
use rustc_middle:: mir:: * ;
20
- use rustc_middle:: ty:: { self , TyCtxt , TypeFoldable , TypeVisitor } ;
20
+ use rustc_middle:: ty:: { self , TyCtxt } ;
21
21
use rustc_target:: abi:: Size ;
22
- use std:: ops:: ControlFlow ;
23
22
24
23
const INDENT : & str = " " ;
25
24
/// Alignment for lining up comments following MIR statements
@@ -669,16 +668,27 @@ pub fn write_allocations<'tcx>(
669
668
}
670
669
}
671
670
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 ) {
674
674
if let ty:: ConstKind :: Value ( val) = c. val ( ) {
675
675
self . 0 . extend ( alloc_ids_from_const ( val) ) ;
676
676
}
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
+ }
678
686
}
679
687
}
688
+
680
689
let mut visitor = CollectAllocIds ( Default :: default ( ) ) ;
681
- body. visit_with ( & mut visitor) ;
690
+ visitor. visit_body ( body) ;
691
+
682
692
// `seen` contains all seen allocations, including the ones we have *not* printed yet.
683
693
// The protocol is to first `insert` into `seen`, and only if that returns `true`
684
694
// then push to `todo`.
0 commit comments