add test for trait recursion

This commit is contained in:
Jaeyong Sung 2022-03-07 12:15:00 +09:00
parent c4a3ccde78
commit e4766776d2
No known key found for this signature in database
GPG key ID: 2B86898CCB2A5486
2 changed files with 17 additions and 1 deletions

View file

@ -86,6 +86,16 @@ impl B for A {
}
}
trait C {
fn hello(a: usize, b: usize) -> usize {
if a == 0 { 1 } else { Self::hello(a - 1, b + 1) }
}
fn hello2(&self, a: usize, b: usize) -> usize {
if a == 0 { 1 } else { self.hello2(a - 1, b + 1) }
}
}
fn ignore(a: usize, _: usize) -> usize {
if a == 1 { 1 } else { ignore(a - 1, 0) }
}

View file

@ -66,5 +66,11 @@ error: parameter is only used in recursion
LL | fn method2(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix with an underscore: `_b`
error: aborting due to 11 previous errors
error: parameter is only used in recursion
--> $DIR/only_used_in_recursion.rs:94:32
|
LL | fn hello2(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix with an underscore: `_b`
error: aborting due to 12 previous errors