From f14a397de7536ea03fbe99c2dafbab6d2aa4acc1 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 2 Oct 2024 15:24:27 -0700 Subject: [PATCH] WIP Enable `clippy::same_name_method` lint It is confusing and error prone to have a method on a type and a trait implemented by that type with the same name. This is particularly bad for something like `::bbox`, which actually calls `Window::bbox_with_popups`. Which is different from `Window::box`. But these three functions have the same type signature. It seems good to disallow this lint in general, but it can be allowed where the methods do the same thing. --- src/backend/renderer/gles/mod.rs | 2 +- src/desktop/wayland/layer.rs | 3 ++- src/lib.rs | 2 +- src/wayland/drm_syncobj/sync_point.rs | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/renderer/gles/mod.rs b/src/backend/renderer/gles/mod.rs index e84e66ff6ce7..c25d519de704 100644 --- a/src/backend/renderer/gles/mod.rs +++ b/src/backend/renderer/gles/mod.rs @@ -2460,7 +2460,7 @@ impl<'frame> GlesFrame<'frame> { /// Optionally allows a custom texture program and matching additional uniforms to be passed in. #[instrument(level = "trace", skip(self), parent = &self.span)] #[profiling::function] - #[allow(clippy::too_many_arguments)] + #[allow(clippy::same_name_method, clippy::too_many_arguments)] pub fn render_texture_from_to( &mut self, texture: &GlesTexture, diff --git a/src/desktop/wayland/layer.rs b/src/desktop/wayland/layer.rs index 1b9db5d7a7a9..a2ea1c64d16c 100644 --- a/src/desktop/wayland/layer.rs +++ b/src/desktop/wayland/layer.rs @@ -530,6 +530,7 @@ impl LayerSurface { /// Returns the underlying [`WlSurface`] #[inline] + #[allow(clippy::same_name_method)] pub fn wl_surface(&self) -> &WlSurface { self.0.surface.wl_surface() } @@ -721,6 +722,6 @@ impl LayerSurface { impl WaylandFocus for LayerSurface { #[inline] fn wl_surface(&self) -> Option> { - Some(Cow::Borrowed(self.0.surface.wl_surface())) + Some(Cow::Borrowed(self.wl_surface())) } } diff --git a/src/lib.rs b/src/lib.rs index 00a7ffe756a9..59a89fb6149b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] +#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, clippy::same_name_method)] // Allow acronyms like EGL #![allow(clippy::upper_case_acronyms)] diff --git a/src/wayland/drm_syncobj/sync_point.rs b/src/wayland/drm_syncobj/sync_point.rs index 3c2738d038b2..83447cf96c64 100644 --- a/src/wayland/drm_syncobj/sync_point.rs +++ b/src/wayland/drm_syncobj/sync_point.rs @@ -79,6 +79,7 @@ impl DrmSyncPoint { } /// Wait for sync point. + #[allow(clippy::same_name_method)] pub fn wait(&self, timeout_nsec: i64) -> io::Result<()> { self.timeline.0.device.syncobj_timeline_wait( &[self.timeline.0.syncobj],