diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-02-22 15:59:29 +0100 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-02-22 15:59:29 +0100 |
| commit | dc0bb69e66e72918a72bac38b57bf7716b3e010d (patch) | |
| tree | 05f1aa0df76e5e9ed29455f4aa8b1b23436c8309 /clippy_lints/src/same_name_method.rs | |
| parent | 31b551fee925cf9ca2d3c37fa09a712ef8e66228 (diff) | |
| parent | d554bcad7914a7fbe01a40371a7917ac0b763494 (diff) | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/same_name_method.rs')
| -rw-r--r-- | clippy_lints/src/same_name_method.rs | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 07806b182f2..7e27f70bcf9 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -47,7 +47,6 @@ struct ExistingName { } impl<'tcx> LateLintPass<'tcx> for SameNameMethod { - #[expect(clippy::too_many_lines)] fn check_crate_post(&mut self, cx: &LateContext<'tcx>) { let mut map = FxHashMap::<Res, ExistingName>::default(); @@ -75,24 +74,23 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { match of_trait { Some(trait_ref) => { - let mut methods_in_trait: BTreeSet<Symbol> = - if let Node::TraitRef(TraitRef { path, .. }) = - cx.tcx.hir_node(trait_ref.hir_ref_id) - && let Res::Def(DefKind::Trait, did) = path.res - { - // FIXME: if - // `rustc_middle::ty::assoc::AssocItems::items` is public, - // we can iterate its keys instead of `in_definition_order`, - // which's more efficient - cx.tcx - .associated_items(did) - .in_definition_order() - .filter(|assoc_item| matches!(assoc_item.kind, AssocKind::Fn)) - .map(|assoc_item| assoc_item.name) - .collect() - } else { - BTreeSet::new() - }; + let mut methods_in_trait: BTreeSet<Symbol> = if let Node::TraitRef(TraitRef { path, .. }) = + cx.tcx.hir_node(trait_ref.hir_ref_id) + && let Res::Def(DefKind::Trait, did) = path.res + { + // FIXME: if + // `rustc_middle::ty::assoc::AssocItems::items` is public, + // we can iterate its keys instead of `in_definition_order`, + // which's more efficient + cx.tcx + .associated_items(did) + .in_definition_order() + .filter(|assoc_item| matches!(assoc_item.kind, AssocKind::Fn)) + .map(|assoc_item| assoc_item.name) + .collect() + } else { + BTreeSet::new() + }; let mut check_trait_method = |method_name: Symbol, trait_method_span: Span| { if let Some((impl_span, hir_id)) = existing_name.impl_methods.get(&method_name) { |
