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 Oct 2, 2024
1 parent df79eeb commit f14a397
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 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 @@ -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,
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()))
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]

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

0 comments on commit f14a397

Please sign in to comment.