You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
}
}
´
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
The text was updated successfully, but these errors were encountered: