diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2025-04-28 08:53:11 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2025-05-06 21:42:04 -0400 |
| commit | a25c195101fe9ef75f0f6cc0092ca2e8054efea3 (patch) | |
| tree | dc04a045b0dded7e9ea36f3adc5fcda23bb5a8af /clippy_utils | |
| parent | fc811f7e2eaf02603c143c0eb8ae3047ea66d1b0 (diff) | |
| download | rust-a25c195101fe9ef75f0f6cc0092ca2e8054efea3.tar.gz rust-a25c195101fe9ef75f0f6cc0092ca2e8054efea3.zip | |
Remove redundant work in `trait_ref_of_method`.
Diffstat (limited to 'clippy_utils')
| -rw-r--r-- | clippy_utils/src/lib.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 0a9c39c41bd..523ed1c8fe7 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -523,12 +523,8 @@ pub fn path_def_id<'tcx>(cx: &LateContext<'_>, maybe_path: &impl MaybePath<'tcx> /// } /// } /// ``` -pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) -> Option<&'tcx TraitRef<'tcx>> { - // Get the implemented trait for the current function - let hir_id = cx.tcx.local_def_id_to_hir_id(def_id); - let parent_impl = cx.tcx.hir_get_parent_item(hir_id); - if parent_impl != hir::CRATE_OWNER_ID - && let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent_impl.def_id) +pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, owner: OwnerId) -> Option<&'tcx TraitRef<'tcx>> { + if let Node::Item(item) = cx.tcx.hir_node(cx.tcx.hir_owner_parent(owner)) && let ItemKind::Impl(impl_) = &item.kind { return impl_.of_trait.as_ref(); |
