Skip to content

Commit fb07f01

Browse files
committed
tail-call-arg-leak
1 parent 921c1da commit fb07f01

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/ui/recursion/recursion-tail-call-no-arg-leak.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
//! This test verifies that tail call optimization does not lead to argument slot leaks.
2+
//! It specifically tests a recursive tail call scenario with a `String` argument
3+
//! to ensure proper memory management and prevent excessive stack usage.
4+
//!
5+
//! Regression test for: <https://github.com/rust-lang/rust/issues/160>
6+
17
//@ run-pass
2-
// use of tail calls causes arg slot leaks, issue #160.
38

4-
fn inner(dummy: String, b: bool) { if b { return inner(dummy, false); } }
9+
fn inner(dummy: String, b: bool) {
10+
if b {
11+
return inner(dummy, false);
12+
}
13+
}
514

615
pub fn main() {
716
inner("hi".to_string(), true);

0 commit comments

Comments
 (0)