about summary refs log tree commit diff
path: root/tests/ui/recursion
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-07-01 20:20:14 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-07-13 00:03:31 +0500
commit98934707eb7824cd48ee3889d4570c1406c39ba4 (patch)
treeea1189bcf19374f2c0c23a546c3133f2999117a9 /tests/ui/recursion
parent47b8a32ca311e2c441f4e7d747bfd75f0045baa1 (diff)
downloadrust-98934707eb7824cd48ee3889d4570c1406c39ba4.tar.gz
rust-98934707eb7824cd48ee3889d4570c1406c39ba4.zip
cleaned up some tests
Additionally, remove unused `tests/ui/auxiliary/svh-*` crates that are duplicates of `tests/ui/svh/auxiliary/svh-*`.
Diffstat (limited to 'tests/ui/recursion')
-rw-r--r--tests/ui/recursion/recursion-tail-call-no-arg-leak.rs11
-rw-r--r--tests/ui/recursion/recursion-tail-cps.rs25
2 files changed, 30 insertions, 6 deletions
diff --git a/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs b/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs
index 234924307c3..fe10b890700 100644
--- a/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs
+++ b/tests/ui/recursion/recursion-tail-call-no-arg-leak.rs
@@ -1,7 +1,14 @@
+//! This test verifies that tail call optimization does not lead to argument slot leaks.
+//!
+//! Regression test for: <https://github.com/rust-lang/rust/issues/160>
+
 //@ run-pass
-// use of tail calls causes arg slot leaks, issue #160.
 
-fn inner(dummy: String, b: bool) { if b { return inner(dummy, false); } }
+fn inner(dummy: String, b: bool) {
+    if b {
+        return inner(dummy, false);
+    }
+}
 
 pub fn main() {
     inner("hi".to_string(), true);
diff --git a/tests/ui/recursion/recursion-tail-cps.rs b/tests/ui/recursion/recursion-tail-cps.rs
index fe99dadf795..9014be0ce98 100644
--- a/tests/ui/recursion/recursion-tail-cps.rs
+++ b/tests/ui/recursion/recursion-tail-cps.rs
@@ -1,17 +1,34 @@
+//! Verify that mutually recursive functions use CPS to avoid overflowing the stack.
+
 //@ run-pass
 
-fn checktrue(rs: bool) -> bool { assert!(rs); return true; }
+fn checktrue(rs: bool) -> bool {
+    assert!(rs);
+    return true;
+}
 
-pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }
+pub fn main() {
+    let k = checktrue;
+    evenk(42, k);
+    oddk(45, k);
+}
 
 fn evenk(n: isize, k: fn(bool) -> bool) -> bool {
     println!("evenk");
     println!("{}", n);
-    if n == 0 { return k(true); } else { return oddk(n - 1, k); }
+    if n == 0 {
+        return k(true);
+    } else {
+        return oddk(n - 1, k);
+    }
 }
 
 fn oddk(n: isize, k: fn(bool) -> bool) -> bool {
     println!("oddk");
     println!("{}", n);
-    if n == 0 { return k(false); } else { return evenk(n - 1, k); }
+    if n == 0 {
+        return k(false);
+    } else {
+        return evenk(n - 1, k);
+    }
 }