You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We already have to_string_in_display. I think it should be enhanced and renamed to recursive_display_impl, meaning any usage of self as Display in impl Display.
new lint: `recursive_format_impl`
The to_string_in_display lint is renamed to recursive_format_impl
A check is added for the use of self formatted with Display or Debug inside any format string in the same impl
The to_string_in_display check is kept as is - like in the format_in_format_args lint
This is my first contribution so please check it for better / more idiomatic checks + error messages. Note the format macro paths are shared with the `format_in_format_args` lint - maybe those could be moved to clippy utils too.
This relates to issues #2691 and #7830
------
changelog: Renamed `to_string_in_display` lint to [`recursive_format_impl`] with new check for any use of self as Display or Debug inside the same format trait impl.
What it does
Aim would be to warn when intended Deref is not triggered correctly.
E.g. for https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c78429c73f85949bd3799a9fdcaa4d74
If we write:
or
Then the Deref to str is not triggered and we got a stack overflow due to recursively calling
Display::fmt
At the moment there are no clippy or rustc warnings or errors, and we just get a stack overflow.
Categories (optional)
clippy::suspicious
What is the advantage of the recommended code over the original code
The recommended code correctly triggers the Deref and avoids the stack overflow.
The text was updated successfully, but these errors were encountered: