Skip to content

Commit

Permalink
WIP Enable clippy::same_name_method lint
Browse files Browse the repository at this point in the history
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 `<Window as SpaceElement>::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.
  • Loading branch information
ids1024 committed Dec 9, 2024
1 parent bae0e9f commit 8d192d0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/backend/renderer/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2459,7 +2459,7 @@ impl GlesFrame<'_> {
/// 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,
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/space/wayland/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{output_update, WindowOutputUserData};
impl WaylandFocus for X11Surface {
#[inline]
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
self.state.lock().unwrap().wl_surface.clone().map(Cow::Owned)
self.wl_surface().map(Cow::Owned)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/desktop/wayland/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -721,6 +722,6 @@ impl LayerSurface {
impl WaylandFocus for LayerSurface {
#[inline]
fn wl_surface(&self) -> Option<Cow<'_, wl_surface::WlSurface>> {
Some(Cow::Borrowed(self.0.surface.wl_surface()))
Some(Cow::Borrowed(self.wl_surface()))
}
}
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![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)]

Expand Down
1 change: 1 addition & 0 deletions src/wayland/drm_syncobj/sync_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
1 change: 1 addition & 0 deletions src/xwayland/xwm/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl X11Surface {
/// shell](crate::wayland::xwayland_shell) protocol on the wayland side,
/// and then committed.
#[inline]
#[allow(clippy::same_name_method)]
pub fn wl_surface(&self) -> Option<WlSurface> {
self.state.lock().unwrap().wl_surface.clone()
}
Expand Down

0 comments on commit 8d192d0

Please sign in to comment.