Skip to content

inherent_to_string false positive #4457

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

Closed
Vlad-Shcherbina opened this issue Aug 26, 2019 · 0 comments · Fixed by #4460
Closed

inherent_to_string false positive #4457

Vlad-Shcherbina opened this issue Aug 26, 2019 · 0 comments · Fixed by #4460
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

@Vlad-Shcherbina
Copy link
Contributor

To reproduce, run Clippy on the following module:

struct S {}

impl S {
    fn to_string(&self, stuff: i32) -> String {
        unimplemented!()
    }
}

It produces the following warning:

warning: implementation of inherent method `to_string(&self) -> String` for type `S`
 --> src\lib.rs:4:5
  |
4 | /     fn to_string(&self, stuff: i32) -> String {
5 | |         unimplemented!()
6 | |     }
  | |_____^
  |
  = note: `#[warn(clippy::inherent_to_string)]` on by default
  = help: implement trait `Display` for type `S` instead
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string

This is incorrect. My to_string has different signature and can't be replaced with Display impl.


> cargo clippy -V
clippy 0.0.212 (05f603e6 2019-08-25)
@flip1995 flip1995 added C-bug Category: Clippy is not doing the correct thing good first issue These issues are a good way to get started with Clippy labels Aug 27, 2019
bors added a commit that referenced this issue Aug 28, 2019
Fix `inherent_to_string` false positive

Fixes #4457

changelog: fixes `inherent_to_string` false positive
@bors bors closed this as completed in 2366661 Aug 28, 2019
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.

2 participants