Skip to content

Commit e476677

Browse files
committed
add test for trait recursion
1 parent c4a3ccd commit e476677

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tests/ui/only_used_in_recursion.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ impl B for A {
8686
}
8787
}
8888

89+
trait C {
90+
fn hello(a: usize, b: usize) -> usize {
91+
if a == 0 { 1 } else { Self::hello(a - 1, b + 1) }
92+
}
93+
94+
fn hello2(&self, a: usize, b: usize) -> usize {
95+
if a == 0 { 1 } else { self.hello2(a - 1, b + 1) }
96+
}
97+
}
98+
8999
fn ignore(a: usize, _: usize) -> usize {
90100
if a == 1 { 1 } else { ignore(a - 1, 0) }
91101
}

tests/ui/only_used_in_recursion.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,11 @@ error: parameter is only used in recursion
6666
LL | fn method2(&self, a: usize, b: usize) -> usize {
6767
| ^ help: if this is intentional, prefix with an underscore: `_b`
6868

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

0 commit comments

Comments
 (0)