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

Incorrect use_self warning #1993

Closed
MasonRemaley opened this issue Aug 26, 2017 · 4 comments
Closed

Incorrect use_self warning #1993

MasonRemaley opened this issue Aug 26, 2017 · 4 comments
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy

Comments

@MasonRemaley
Copy link

I believe I've come across a case where clippy gives a use_self warning but shouldn't:

#![warn(use_self)]

pub trait Foo {
    fn foo() -> Option<()>;
}

impl Foo for Option<i32> {
    fn foo() -> Option<()> { // can't use `Self` here as `Self` is `Option<i32>` not `Option<()>`
        unimplemented!()
    }
}

fn main() {}

(playground link)

It's possible this is actually correct and it just wants me to specify Self with different params in which case I'm just not sure what the syntax is for that.


Potentially related, I'd actually be interested in helping out with Clippy. If this seems like an easy issue to get started on I'd be happy to try to fix it myself!

@oli-obk
Copy link
Contributor

oli-obk commented Aug 26, 2017

Potentially related, I'd actually be interested in helping out with Clippy. If this seems like an easy issue to get started on I'd be happy to try to fix it myself!

Awesome. Currently we bail out if the type has any lifetimes. That means we don't lint some cases that should be linted. To fix this once and for all you'd need to remove the current lifetime check on the impl, and instead check whether the found path does not only match by name, but also by the lifetime and generics.

@oli-obk oli-obk added good-first-issue These issues are a good way to get started with Clippy C-bug Category: Clippy is not doing the correct thing labels Aug 26, 2017
@MasonRemaley
Copy link
Author

Cool okay, sounds straightforward enough--I'll get started on this tomorrow.

@otavio
Copy link

otavio commented Oct 6, 2018

I was looking at the use_self and tested your playground link and it seems this issue does not happen anymore. I think it can be closed.

@ghost
Copy link

ghost commented Oct 7, 2018

Yes, it's fixed. Updated playground

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants