Skip to content

Lint methods which have "self" argument but don't use it. #4550

Closed
@iddm

Description

@iddm

If we have a code like this:

struct A;
impl A {
    fn method(&self) {
        // do something, but don't use self.
    }
}

We could highlight "unused self" and advise to refactor it to a static method or a function. The same lint has been in Python language for a decade, I believe.

Note: if the self argument is unused within a trait, we should not lint this, because this becomes a part of a generic interface, which could have been done intentionally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-complexityLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions