impl !PartialOrd for HirId

This commit is contained in:
Oli Scherer 2025-03-17 12:23:53 +00:00
parent 945162696d
commit ea971488dd

View file

@ -153,9 +153,15 @@ impl LateLintPass<'_> for MacroUseImports {
[] | [_] => return,
[root, item] => {
if !check_dup.contains(&(*item).to_string()) {
used.entry(((*root).to_string(), span, hir_id))
.or_insert_with(Vec::new)
.push((*item).to_string());
used.entry((
(*root).to_string(),
span,
hir_id.local_id,
cx.tcx.def_path_hash(hir_id.owner.def_id.into()),
))
.or_insert_with(|| (vec![], hir_id))
.0
.push((*item).to_string());
check_dup.push((*item).to_string());
}
},
@ -171,15 +177,27 @@ impl LateLintPass<'_> for MacroUseImports {
}
})
.collect::<Vec<_>>();
used.entry(((*root).to_string(), span, hir_id))
.or_insert_with(Vec::new)
.push(filtered.join("::"));
used.entry((
(*root).to_string(),
span,
hir_id.local_id,
cx.tcx.def_path_hash(hir_id.owner.def_id.into()),
))
.or_insert_with(|| (vec![], hir_id))
.0
.push(filtered.join("::"));
check_dup.extend(filtered);
} else {
let rest = rest.to_vec();
used.entry(((*root).to_string(), span, hir_id))
.or_insert_with(Vec::new)
.push(rest.join("::"));
used.entry((
(*root).to_string(),
span,
hir_id.local_id,
cx.tcx.def_path_hash(hir_id.owner.def_id.into()),
))
.or_insert_with(|| (vec![], hir_id))
.0
.push(rest.join("::"));
check_dup.extend(rest.iter().map(ToString::to_string));
}
},
@ -190,7 +208,7 @@ impl LateLintPass<'_> for MacroUseImports {
// If mac_refs is not empty we have encountered an import we could not handle
// such as `std::prelude::v1::foo` or some other macro that expands to an import.
if self.mac_refs.is_empty() {
for ((root, span, hir_id), path) in used {
for ((root, span, ..), (path, hir_id)) in used {
let import = if let [single] = &path[..] {
format!("{root}::{single}")
} else {