@@ -153,9 +153,15 @@ impl LateLintPass<'_> for MacroUseImports {
153
153
[ ] | [ _] => return ,
154
154
[ root, item] => {
155
155
if !check_dup. contains ( & ( * item) . to_string ( ) ) {
156
- used. entry ( ( ( * root) . to_string ( ) , span, hir_id) )
157
- . or_insert_with ( Vec :: new)
158
- . push ( ( * item) . to_string ( ) ) ;
156
+ used. entry ( (
157
+ ( * root) . to_string ( ) ,
158
+ span,
159
+ hir_id. local_id ,
160
+ cx. tcx . def_path_hash ( hir_id. owner . def_id . into ( ) ) ,
161
+ ) )
162
+ . or_insert_with ( || ( vec ! [ ] , hir_id) )
163
+ . 0
164
+ . push ( ( * item) . to_string ( ) ) ;
159
165
check_dup. push ( ( * item) . to_string ( ) ) ;
160
166
}
161
167
} ,
@@ -171,15 +177,27 @@ impl LateLintPass<'_> for MacroUseImports {
171
177
}
172
178
} )
173
179
. collect :: < Vec < _ > > ( ) ;
174
- used. entry ( ( ( * root) . to_string ( ) , span, hir_id) )
175
- . or_insert_with ( Vec :: new)
176
- . push ( filtered. join ( "::" ) ) ;
180
+ used. entry ( (
181
+ ( * root) . to_string ( ) ,
182
+ span,
183
+ hir_id. local_id ,
184
+ cx. tcx . def_path_hash ( hir_id. owner . def_id . into ( ) ) ,
185
+ ) )
186
+ . or_insert_with ( || ( vec ! [ ] , hir_id) )
187
+ . 0
188
+ . push ( filtered. join ( "::" ) ) ;
177
189
check_dup. extend ( filtered) ;
178
190
} else {
179
191
let rest = rest. to_vec ( ) ;
180
- used. entry ( ( ( * root) . to_string ( ) , span, hir_id) )
181
- . or_insert_with ( Vec :: new)
182
- . push ( rest. join ( "::" ) ) ;
192
+ used. entry ( (
193
+ ( * root) . to_string ( ) ,
194
+ span,
195
+ hir_id. local_id ,
196
+ cx. tcx . def_path_hash ( hir_id. owner . def_id . into ( ) ) ,
197
+ ) )
198
+ . or_insert_with ( || ( vec ! [ ] , hir_id) )
199
+ . 0
200
+ . push ( rest. join ( "::" ) ) ;
183
201
check_dup. extend ( rest. iter ( ) . map ( ToString :: to_string) ) ;
184
202
}
185
203
} ,
@@ -190,7 +208,7 @@ impl LateLintPass<'_> for MacroUseImports {
190
208
// If mac_refs is not empty we have encountered an import we could not handle
191
209
// such as `std::prelude::v1::foo` or some other macro that expands to an import.
192
210
if self . mac_refs . is_empty ( ) {
193
- for ( ( root, span, hir_id ) , path) in used {
211
+ for ( ( root, span, .. ) , ( path, hir_id ) ) in used {
194
212
let import = if let [ single] = & path[ ..] {
195
213
format ! ( "{root}::{single}" )
196
214
} else {
0 commit comments