Closed
Description
We found a simple way to cause infinite recursion in a sneaky way, it would be great to be able to have this as a warning or something.
When implementing a trait, that trait can be invoked inside the trait implementation. Causing hard to detect bugs.
Simplest example:
use std::fmt;
pub struct S;
impl fmt::Display for S {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
}
}
fn main() {
print!("{}", S);
}
Activity
jonas-schievink commentedon Jul 24, 2020
Duplicate of #57965
unconditional_recursion
lint work across function calls #57965jonas-schievink commentedon Jul 24, 2020
or rather, #58035