Skip to content

unused_self: respect avoid-breaking-exported-api #9195

Closed
@Xiretza

Description

@Xiretza

Description

unused_self currently suggests converting methods to associated functions even for public APIs:

#![deny(clippy::unused_self)]

pub struct Foo;

impl Foo {
    pub fn test(&self) {}
}
error: unused `self` argument
 --> src/main.rs:6:17
  |
6 |     pub fn test(&self) {}
  |                 ^^^^^
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(clippy::unused_self)]
  |         ^^^^^^^^^^^^^^^^^^^
  = help: consider refactoring to a associated function
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_self

unused_self should instead respect the avoid-breaking-exported-api option like several other lints and only trigger for public APIs if the option is set to false.

Version

rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: x86_64-unknown-linux-gnu
release: 1.62.0
LLVM version: 14.0.5

Additional Labels

@rustbot label +C-enhancement

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions