@@ -2,7 +2,7 @@ use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
2
2
use crate :: hir:: { self , intravisit, HirId , ItemLocalId } ;
3
3
use syntax:: ast:: NodeId ;
4
4
use crate :: hir:: itemlikevisit:: ItemLikeVisitor ;
5
- use rustc_data_structures:: fx:: FxHashMap ;
5
+ use rustc_data_structures:: fx:: FxHashSet ;
6
6
use rustc_data_structures:: sync:: { Lock , ParallelIterator , par_iter} ;
7
7
8
8
pub 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>) {
30
30
struct HirIdValidator < ' a , ' hir : ' a > {
31
31
hir_map : & ' a hir:: map:: Map < ' hir > ,
32
32
owner_def_index : Option < DefIndex > ,
33
- hir_ids_seen : FxHashMap < ItemLocalId , NodeId > ,
33
+ hir_ids_seen : FxHashSet < ItemLocalId > ,
34
34
errors : & ' a Lock < Vec < String > > ,
35
35
}
36
36
@@ -90,16 +90,19 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
90
90
91
91
// There's always at least one entry for the owning item itself
92
92
let max = self . hir_ids_seen
93
- . keys ( )
93
+ . iter ( )
94
94
. map ( |local_id| local_id. as_usize ( ) )
95
95
. max ( )
96
96
. expect ( "owning item has no entry" ) ;
97
97
98
98
if max != self . hir_ids_seen . len ( ) - 1 {
99
99
// Collect the missing ItemLocalIds
100
100
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 ( ) ;
103
106
104
107
// Try to map those to something more useful
105
108
let mut missing_items = Vec :: with_capacity ( missing. len ( ) ) ;
@@ -133,8 +136,12 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
133
136
max,
134
137
missing_items,
135
138
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) ) )
138
145
. collect:: <Vec <_>>( ) ) ) ;
139
146
}
140
147
}
@@ -164,9 +171,7 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
164
171
self . hir_map. def_path( DefId :: local( owner) ) . to_string_no_crate( ) ) ) ;
165
172
}
166
173
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 ) ;
170
175
}
171
176
172
177
fn visit_impl_item_ref ( & mut self , _: & ' hir hir:: ImplItemRef ) {
0 commit comments