rustc should warn when the implementation of Display requires to display self #58035
Labels
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
rustc
should fail or warn when the implementation of theDisplay
trait of a strcut requires to display it. Indeed there is a stack overflow as the code is recursively called.rustc
already detect recursion issues in other cases.Such mistake can happen when using "{}" instead of "{:?}" for debug purpose.
This code:
producde this compilation message and test error:
Although to have this crash is normal, the compiler should raise a warning exactly as it does for the recursive function.
With this version
although the crash is slightly different:
compilation warning should be the same.
I'm writting this issue because I guess it can be detected by the compiler as
Display
(orDebug
) belong to the language.Meta
The text was updated successfully, but these errors were encountered: