Skip to content

unused_self unsexpected positive with #![allow(unused)] #10117

Closed
@tgross35

Description

@tgross35

Summary

When allow(unused) is enabled (e.g. during API development), it is surprising that the unused_self lint throws an error - especially when there is only a todo!() in the body. I would expect either that allowing unused disables the unused_self warning, or that the presence of todo should ignore it (to be detected by the todo lint)

Lint Name

unused_self

Reproducer

I tried this code playground link:

#![allow(unused)]
#![warn(clippy::unused_self)]

struct X;

impl X {
    pub fn test_fn(&self) {
        todo!();
    }
}

I saw this happen:

warning: unused `self` argument
 --> src/lib.rs:7:20
  |
7 |     pub fn test_fn(&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
note: the lint level is defined here
 --> src/lib.rs:2:9
  |
2 | #![warn(clippy::unused_self)]
  |         ^^^^^^^^^^^^^^^^^^^

warning: `playground` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.39s

I expected to see this happen: no lint

Version

0.1.68 nightly (playground)

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions