Open gftea opened 4 months ago
Macros, like the one you call there, are pretty good at obscuring these impl details, but yeah we should probably warn.
I could have sworn there was a similar report about using to_string
within an impl Display for
from maybe 2017/2018, but can't find it 😅
@workingjubilee in the wild I've seen that simple cases where the chain repeats after just one or two jumps represent the bulk of them, so beyond the obfuscation issues, I'm convincing myself that a very limited call-graph analysis to look for unconditional recursivity is warranted. It's funny that it's always involving Display
or Debug
though 😄
Edit: found it https://github.com/rust-lang/rust/issues/45838
And regarding the 2nd suggestion, what is your view
there is no use case for using
:
as standalone formatter, and it is better the compiler to emit error to use : as standalone formatter because it is likely user want to use:?
but miss?
by mistake,
there is no use case for using
:
as standalone formatter, and it is better the compiler to emit error to use : as standalone formatter because it is likely user want to use:?
but miss?
by mistake,
Unlikely to work, there's probably a crate out there that uses it, so it can't be removed due to backward compatibility guarantees.
there is no use case for using
:
as standalone formatter, and it is better the compiler to emit error to use : as standalone formatter because it is likely user want to use:?
but miss?
by mistake,Unlikely to work, there's probably a crate out there that uses it, so it can't be removed due to backward compatibility guarantees.
can be a warnings?
Yes, we can lint on that. In fact we already lint on a few bad format_args!
inputs.
Code
code cause recursion stack overflow
Current output
Runtime error instead of compile time error at present
Desired output
In a large code base, such small mistake is hard to locate because it does not point out which recursion call cause stack overflow.
Rationale and extra context
:
as standalone formatter, and it is better the compiler to emit error to use:
as standalone formatter because it is likely user want to use:?
but drop?
by mistake,Other cases
No response
Rust Version
Anything else?
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=15e6928ea61ea7e8ac7072fa82875e97