@@ -3,8 +3,6 @@ use std::fmt;
33use crate :: mir:: interpret:: { alloc_range, AllocId , Allocation , Pointer , Scalar } ;
44use crate :: ty:: { self , Instance , PolyTraitRef , Ty , TyCtxt } ;
55use rustc_ast:: Mutability ;
6- use rustc_data_structures:: fx:: FxHashSet ;
7- use rustc_hir:: def_id:: DefId ;
86use rustc_macros:: HashStable ;
97
108#[ derive( Clone , Copy , PartialEq , HashStable ) ]
@@ -42,45 +40,12 @@ impl<'tcx> fmt::Debug for VtblEntry<'tcx> {
4240impl < ' tcx > TyCtxt < ' tcx > {
4341 pub const COMMON_VTABLE_ENTRIES : & ' tcx [ VtblEntry < ' tcx > ] =
4442 & [ VtblEntry :: MetadataDropInPlace , VtblEntry :: MetadataSize , VtblEntry :: MetadataAlign ] ;
45-
46- pub fn supertrait_def_ids ( self , trait_def_id : DefId ) -> SupertraitDefIds < ' tcx > {
47- SupertraitDefIds {
48- tcx : self ,
49- stack : vec ! [ trait_def_id] ,
50- visited : Some ( trait_def_id) . into_iter ( ) . collect ( ) ,
51- }
52- }
5343}
5444
5545pub const COMMON_VTABLE_ENTRIES_DROPINPLACE : usize = 0 ;
5646pub const COMMON_VTABLE_ENTRIES_SIZE : usize = 1 ;
5747pub const COMMON_VTABLE_ENTRIES_ALIGN : usize = 2 ;
5848
59- pub struct SupertraitDefIds < ' tcx > {
60- tcx : TyCtxt < ' tcx > ,
61- stack : Vec < DefId > ,
62- visited : FxHashSet < DefId > ,
63- }
64-
65- impl Iterator for SupertraitDefIds < ' _ > {
66- type Item = DefId ;
67-
68- fn next ( & mut self ) -> Option < DefId > {
69- let def_id = self . stack . pop ( ) ?;
70- let predicates = self . tcx . explicit_super_predicates_of ( def_id) ;
71- let visited = & mut self . visited ;
72- self . stack . extend (
73- predicates
74- . predicates
75- . iter ( )
76- . filter_map ( |( pred, _) | pred. as_trait_clause ( ) )
77- . map ( |trait_ref| trait_ref. def_id ( ) )
78- . filter ( |& super_def_id| visited. insert ( super_def_id) ) ,
79- ) ;
80- Some ( def_id)
81- }
82- }
83-
8449// Note that we don't have access to a self type here, this has to be purely based on the trait (and
8550// supertrait) definitions. That means we can't call into the same vtable_entries code since that
8651// returns a specific instantiation (e.g., with Vacant slots when bounds aren't satisfied). The goal
0 commit comments