Add regression ui test for unconditional_recursion
lint on PartialEq
This commit is contained in:
parent
c8cd09a8e6
commit
132667288a
@ -264,6 +264,28 @@ impl S13 {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// test code goes here
|
||||
struct S14 {
|
||||
field: String,
|
||||
}
|
||||
|
||||
impl PartialEq for S14 {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
// Should not warn!
|
||||
self.field.eq(&other.field)
|
||||
}
|
||||
}
|
||||
|
||||
struct S15<'a> {
|
||||
field: &'a S15<'a>,
|
||||
}
|
||||
|
||||
impl PartialEq for S15<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
//~^ ERROR: function cannot return without recursing
|
||||
let mine = &self.field;
|
||||
let theirs = &other.field;
|
||||
mine.eq(theirs)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -340,5 +340,22 @@ note: recursive call site
|
||||
LL | Self::default()
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 26 previous errors
|
||||
error: function cannot return without recursing
|
||||
--> $DIR/unconditional_recursion.rs:283:5
|
||||
|
|
||||
LL | / fn eq(&self, other: &Self) -> bool {
|
||||
LL | |
|
||||
LL | | let mine = &self.field;
|
||||
LL | | let theirs = &other.field;
|
||||
LL | | mine.eq(theirs)
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
note: recursive call site
|
||||
--> $DIR/unconditional_recursion.rs:287:9
|
||||
|
|
||||
LL | mine.eq(theirs)
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 27 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user