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

Audit required: Function call in default() that returns Self RS-A1008 #2686

Closed
philipjonsen opened this issue Sep 22, 2024 · 1 comment
Closed

Comments

@philipjonsen
Copy link

philipjonsen commented Sep 22, 2024

Description
The default() function in the Default trait is used to create a default instance of the type. While implementing this, if a function call returns the same type, it could possibly create an infinite loop by calling default() itself.

Consider revisiting this implementation.

Bad practice;
`struct A(i32);

impl A {
fn new() -> Self {
Self::default()
}
}

impl Default for A {
fn default() -> Self {
// This call will create an infinite loop
Self::new()
}
}
´

Found call returning Self in default()
https://github.com/nitro/blob/master/arbitrator/prover/src/programs/counter.rs#L40-L42

@joshuacolvin0
Copy link
Member

This is just a linter false positive

@joshuacolvin0 joshuacolvin0 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
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