Skip to content

False positive for inherent_to_string_shadow_display? #4396

Open
@huxi

Description

@huxi

I think I found a false positive or at least questionable case of inherent_to_string_shadow_display rule triggering.

The place this rule is (or rather "was", since I disabled it) triggered:
https://github.com/huxi/rusty_ulid/blob/72ac82736311981d12c339b78756049f48406179/src/lib.rs#L557

The place where the method in question is used to actually implement Display:
https://github.com/huxi/rusty_ulid/blob/72ac82736311981d12c339b78756049f48406179/src/lib.rs#L571

This boils down to a situation where a type has an efficient implementation of fn to_string(&self) -> String that is used to implement fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> of fmt::Display.

I think this case (method is used to implement trait) shouldn't trigger the rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesI-false-positiveIssue: The lint was triggered on code it shouldn't haveL-suggestionLint: Improving, adding or fixing lint suggestionsgood 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