-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Don't use to_string
in impl Display
#5831
Conversation
r? @flip1995 (rust_highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #5868) made this pull request unmergeable. Please resolve the merge conflicts. |
6c1daec
to
95f0a2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. We can use the lint infrastructure better, to make the code more readable though.
0932baa
to
84315f7
Compare
if match_def_path(cx, did, &paths::DISPLAY_TRAIT); | ||
then { | ||
true | ||
} else { | ||
false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the clippy::needless_bool
lint triggering here: You can simplify this to:
if match_def_path(cx, did, &paths::DISPLAY_TRAIT); | |
then { | |
true | |
} else { | |
false | |
} | |
then { | |
match_def_path(cx, did, &paths::DISPLAY_TRAIT) | |
} else { | |
false | |
} |
Clippy is great 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
Please also address the other two dogfood errors:
|
84315f7
to
8e54997
Compare
Thanks! @bors r+ |
📌 Commit 8e54997 has been approved by |
@bors retry (for changelog) |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
/// ``` | ||
pub TO_STRING_IN_DISPLAY, | ||
correctness, | ||
"to_string method used while implementing Display trait" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"`to_string` method used while implementing `Display` trait"
cx, | ||
TO_STRING_IN_DISPLAY, | ||
expr.span, | ||
"Using to_string in fmt::Display implementation might lead to infinite recursion", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"using to_string
in fmt::Display
implementation might lead to infinite recursion",
…display, r=yaahc Improve lint message in `to_string_in_display` This is a follow-up of #5831. changelog: none
fixes #3876
this PR is derived from Toxyxer's implementation.
changelog: add [
to_string_in_display
] lint