Add tests for extension of unconditional_recursion lint on Default trait
This commit is contained in:
parent
2666f39d3e
commit
bf5c0d8334
2 changed files with 49 additions and 2 deletions
|
|
@ -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 @@ impl std::string::ToString for S11 {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue