@@ -2,7 +2,7 @@ use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
22use crate :: hir:: { self , intravisit, HirId , ItemLocalId } ;
33use syntax:: ast:: NodeId ;
44use crate :: hir:: itemlikevisit:: ItemLikeVisitor ;
5- use rustc_data_structures:: fx:: FxHashMap ;
5+ use rustc_data_structures:: fx:: FxHashSet ;
66use rustc_data_structures:: sync:: { Lock , ParallelIterator , par_iter} ;
77
88pub fn check_crate < ' hir > ( hir_map : & hir:: map:: Map < ' hir > ) {
@@ -30,7 +30,7 @@ pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) {
3030struct HirIdValidator < ' a , ' hir : ' a > {
3131 hir_map : & ' a hir:: map:: Map < ' hir > ,
3232 owner_def_index : Option < DefIndex > ,
33- hir_ids_seen : FxHashMap < ItemLocalId , NodeId > ,
33+ hir_ids_seen : FxHashSet < ItemLocalId > ,
3434 errors : & ' a Lock < Vec < String > > ,
3535}
3636
@@ -90,16 +90,19 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
9090
9191 // There's always at least one entry for the owning item itself
9292 let max = self . hir_ids_seen
93- . keys ( )
93+ . iter ( )
9494 . map ( |local_id| local_id. as_usize ( ) )
9595 . max ( )
9696 . expect ( "owning item has no entry" ) ;
9797
9898 if max != self . hir_ids_seen . len ( ) - 1 {
9999 // Collect the missing ItemLocalIds
100100 let missing: Vec < _ > = ( 0 ..= max as u32 )
101- . filter ( |& i| !self . hir_ids_seen . contains_key ( & ItemLocalId :: from_u32 ( i) ) )
102- . collect ( ) ;
101+ . filter ( |& i| !self . hir_ids_seen
102+ . iter ( )
103+ . find ( |& local_id| local_id == & ItemLocalId :: from_u32 ( i) )
104+ . is_some ( )
105+ ) . collect ( ) ;
103106
104107 // Try to map those to something more useful
105108 let mut missing_items = Vec :: with_capacity ( missing. len ( ) ) ;
@@ -133,8 +136,12 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
133136 max,
134137 missing_items,
135138 self . hir_ids_seen
136- . values( )
137- . map( |n| format!( "({:?} {})" , n, self . hir_map. node_to_string( * n) ) )
139+ . iter( )
140+ . map( |& local_id| HirId {
141+ owner: owner_def_index,
142+ local_id,
143+ } )
144+ . map( |h| format!( "({:?} {})" , h, self . hir_map. hir_to_string( h) ) )
138145 . collect:: <Vec <_>>( ) ) ) ;
139146 }
140147 }
@@ -164,9 +171,7 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
164171 self . hir_map. def_path( DefId :: local( owner) ) . to_string_no_crate( ) ) ) ;
165172 }
166173
167- let node_id = self . hir_map . hir_to_node_id ( hir_id) ;
168-
169- self . hir_ids_seen . insert ( hir_id. local_id , node_id) ;
174+ self . hir_ids_seen . insert ( hir_id. local_id ) ;
170175 }
171176
172177 fn visit_impl_item_ref ( & mut self , _: & ' hir hir:: ImplItemRef ) {
0 commit comments