rust-lang/rust-clippy

False positive for inherent_to_string_shadow_display?

Open

#4,396 创建于 2019年8月16日

在 GitHub 查看
 (16 评论) (0 反应) (0 负责人)Rust (1,391 fork)batch import
C-bugC-enhancementI-false-positiveL-suggestiongood first issue

仓库指标

Star
 (10,406 star)
PR 合并指标
 (平均合并 19天 22小时) (30 天内合并 113 个 PR)

描述

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.

贡献者指南