Skip to content

Commit ea97148

Browse files
committed
impl !PartialOrd for HirId
1 parent 9451626 commit ea97148

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

clippy_lints/src/macro_use.rs

+28-10
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,15 @@ impl LateLintPass<'_> for MacroUseImports {
153153
[] | [_] => return,
154154
[root, item] => {
155155
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());
159165
check_dup.push((*item).to_string());
160166
}
161167
},
@@ -171,15 +177,27 @@ impl LateLintPass<'_> for MacroUseImports {
171177
}
172178
})
173179
.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("::"));
177189
check_dup.extend(filtered);
178190
} else {
179191
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("::"));
183201
check_dup.extend(rest.iter().map(ToString::to_string));
184202
}
185203
},
@@ -190,7 +208,7 @@ impl LateLintPass<'_> for MacroUseImports {
190208
// If mac_refs is not empty we have encountered an import we could not handle
191209
// such as `std::prelude::v1::foo` or some other macro that expands to an import.
192210
if self.mac_refs.is_empty() {
193-
for ((root, span, hir_id), path) in used {
211+
for ((root, span, ..), (path, hir_id)) in used {
194212
let import = if let [single] = &path[..] {
195213
format!("{root}::{single}")
196214
} else {

0 commit comments

Comments
 (0)