Add tests for extension of unconditional_recursion
lint on Default
trait
This commit is contained in:
parent
2666f39d3e
commit
bf5c0d8334
@ -1,7 +1,7 @@
|
||||
//@no-rustfix
|
||||
|
||||
#![warn(clippy::unconditional_recursion)]
|
||||
#![allow(clippy::partialeq_ne_impl)]
|
||||
#![allow(clippy::partialeq_ne_impl, clippy::default_constructed_unit_structs)]
|
||||
|
||||
enum Foo {
|
||||
A,
|
||||
@ -232,6 +232,38 @@ fn to_string(&self) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
struct S12;
|
||||
|
||||
impl std::default::Default for S12 {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl S12 {
|
||||
fn new() -> Self {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
Self::default()
|
||||
}
|
||||
|
||||
fn bar() -> Self {
|
||||
// Should not warn!
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct S13 {
|
||||
f: u32,
|
||||
}
|
||||
|
||||
impl S13 {
|
||||
fn new() -> Self {
|
||||
// Shoud not warn!
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// test code goes here
|
||||
}
|
||||
|
@ -325,5 +325,20 @@ note: recursive call site
|
||||
LL | mine == theirs
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 25 previous errors
|
||||
error: function cannot return without recursing
|
||||
--> $DIR/unconditional_recursion.rs:244:5
|
||||
|
|
||||
LL | / fn new() -> Self {
|
||||
LL | |
|
||||
LL | | Self::default()
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
note: recursive call site
|
||||
--> $DIR/unconditional_recursion.rs:246:9
|
||||
|
|
||||
LL | Self::default()
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 26 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user