Skip to content

inherent_to_string false positive #4457

Closed
@Vlad-Shcherbina

Description

@Vlad-Shcherbina

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thinggood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions