Skip to content

Commit 5f3d385

Browse files
committed
Auto merge of rust-lang#120812 - compiler-errors:impl-sorting, r=lcnr
Remove unnecessary impl sorting in queries and metadata Removes unnecessary impl sorting because queries already return their keys in HIR definition order: rust-lang#120371 (comment) r? `@cjgillot` or `@lcnr` -- unless I totally misunderstood what was being asked for here? 😆 fixes rust-lang#120371
2 parents 8051d07 + 8a0ccd3 commit 5f3d385

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

clippy_lints/src/inherent_impl.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
5656
let Ok(impls) = cx.tcx.crate_inherent_impls(()) else {
5757
return;
5858
};
59-
let inherent_impls = cx
60-
.tcx
61-
.with_stable_hashing_context(|hcx| impls.inherent_impls.to_sorted(&hcx, true));
6259

63-
for (_, impl_ids) in inherent_impls.into_iter().filter(|(&id, impls)| {
64-
impls.len() > 1
60+
for (&id, impl_ids) in &impls.inherent_impls {
61+
if impl_ids.len() < 2
6562
// Check for `#[allow]` on the type definition
66-
&& !is_lint_allowed(
63+
|| is_lint_allowed(
6764
cx,
6865
MULTIPLE_INHERENT_IMPL,
6966
cx.tcx.local_def_id_to_hir_id(id),
70-
)
71-
}) {
67+
) {
68+
continue;
69+
}
70+
7271
for impl_id in impl_ids.iter().map(|id| id.expect_local()) {
7372
let impl_ty = cx.tcx.type_of(impl_id).instantiate_identity();
7473
match type_map.entry(impl_ty) {

0 commit comments

Comments
 (0)