Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
iddm opened this issue Sep 17, 2019 · 2 comments · Fixed by #4619
Closed

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

iddm opened this issue Sep 17, 2019 · 2 comments · Fixed by #4619
Labels
A-lint Area: New lints L-complexity Lint: Belongs in the complexity lint group L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@iddm
Copy link
Contributor

iddm commented Sep 17, 2019

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.

@flip1995 flip1995 added L-complexity Lint: Belongs in the complexity lint group L-suggestion Lint: Improving, adding or fixing lint suggestions A-lint Area: New lints labels Sep 17, 2019
@james9909
Copy link
Contributor

Hi, I'd like to work on this issue :)

@iddm
Copy link
Contributor Author

iddm commented Oct 2, 2019

Please note, that in such methods we should also treat any form of accepting self argument there: by reference, mutable reference, pointers, moving, anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints L-complexity Lint: Belongs in the complexity lint group L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants