mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 14:38:46 +00:00
Add ui test for UNCONDITIONAL_RECURSION
lint on ToString
impl
This commit is contained in:
parent
ab2d1c28d5
commit
d161f3b559
2 changed files with 62 additions and 1 deletions
|
@ -158,6 +158,34 @@ struct S5;
|
||||||
impl_partial_eq!(S5);
|
impl_partial_eq!(S5);
|
||||||
//~^ ERROR: function cannot return without recursing
|
//~^ ERROR: function cannot return without recursing
|
||||||
|
|
||||||
|
struct S6;
|
||||||
|
|
||||||
|
impl std::string::ToString for S6 {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
//~^ ERROR: function cannot return without recursing
|
||||||
|
self.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S7;
|
||||||
|
|
||||||
|
impl std::string::ToString for S7 {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
//~^ ERROR: function cannot return without recursing
|
||||||
|
let x = self;
|
||||||
|
x.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S8;
|
||||||
|
|
||||||
|
impl std::string::ToString for S8 {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
//~^ ERROR: function cannot return without recursing
|
||||||
|
(self as &Self).to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// test code goes here
|
// test code goes here
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,39 @@ LL | self.eq(other)
|
||||||
|
|
|
|
||||||
= help: a `loop` may express intention better if this is on purpose
|
= help: a `loop` may express intention better if this is on purpose
|
||||||
|
|
||||||
|
error: function cannot return without recursing
|
||||||
|
--> $DIR/unconditional_recursion.rs:164:5
|
||||||
|
|
|
||||||
|
LL | fn to_string(&self) -> String {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||||
|
LL |
|
||||||
|
LL | self.to_string()
|
||||||
|
| ---------------- recursive call site
|
||||||
|
|
|
||||||
|
= help: a `loop` may express intention better if this is on purpose
|
||||||
|
|
||||||
|
error: function cannot return without recursing
|
||||||
|
--> $DIR/unconditional_recursion.rs:173:5
|
||||||
|
|
|
||||||
|
LL | fn to_string(&self) -> String {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||||
|
...
|
||||||
|
LL | x.to_string()
|
||||||
|
| ------------- recursive call site
|
||||||
|
|
|
||||||
|
= help: a `loop` may express intention better if this is on purpose
|
||||||
|
|
||||||
|
error: function cannot return without recursing
|
||||||
|
--> $DIR/unconditional_recursion.rs:183:5
|
||||||
|
|
|
||||||
|
LL | fn to_string(&self) -> String {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||||
|
LL |
|
||||||
|
LL | (self as &Self).to_string()
|
||||||
|
| --------------------------- recursive call site
|
||||||
|
|
|
||||||
|
= help: a `loop` may express intention better if this is on purpose
|
||||||
|
|
||||||
error: function cannot return without recursing
|
error: function cannot return without recursing
|
||||||
--> $DIR/unconditional_recursion.rs:12:5
|
--> $DIR/unconditional_recursion.rs:12:5
|
||||||
|
|
|
|
||||||
|
@ -247,5 +280,5 @@ LL | impl_partial_eq!(S5);
|
||||||
| -------------------- in this macro invocation
|
| -------------------- in this macro invocation
|
||||||
= note: this error originates in the macro `impl_partial_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `impl_partial_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 19 previous errors
|
error: aborting due to 22 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue