Skip to content
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

Detect internal implementation usage that leads to infinite recursion #74714

Closed
TotalKrill opened this issue Jul 24, 2020 · 2 comments
Closed

Comments

@TotalKrill
Copy link

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);
}

link to playground

@jonas-schievink
Copy link
Contributor

Duplicate of #57965

@jonas-schievink jonas-schievink marked this as a duplicate of #57965 Jul 24, 2020
@jonas-schievink
Copy link
Contributor

or rather, #58035

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants