Skip to content

Commit 75cc92b

Browse files
committed
Add test
1 parent a4ee413 commit 75cc92b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

tests/ui/only_used_in_recursion.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,15 @@ impl E<()> for () {
169169
}
170170
}
171171

172+
fn overwritten_param(flag: u32, mut a: usize) -> usize {
173+
if flag == 0 {
174+
return 0;
175+
} else if flag > 5 {
176+
a += flag as usize;
177+
} else {
178+
a = 5;
179+
}
180+
overwritten_param(flag, a)
181+
}
182+
172183
fn main() {}

tests/ui/only_used_in_recursion.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,17 @@ note: parameter used here
227227
LL | _with_closure(Some(x), b, f)
228228
| ^
229229

230-
error: aborting due to 19 previous errors
230+
error: parameter is only used in recursion
231+
--> $DIR/only_used_in_recursion.rs:172:37
232+
|
233+
LL | fn overwritten_param(flag: u32, mut a: usize) -> usize {
234+
| ^ help: if this is intentional, prefix it with an underscore: `_a`
235+
|
236+
note: parameter used here
237+
--> $DIR/only_used_in_recursion.rs:180:29
238+
|
239+
LL | overwritten_param(flag, a)
240+
| ^
241+
242+
error: aborting due to 20 previous errors
231243

0 commit comments

Comments
 (0)