about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-07 20:49:45 +1000
committerGitHub <noreply@github.com>2025-08-07 20:49:45 +1000
commit3636042664c9d5fade6a13079e0fe0ea19bd47df (patch)
treef0dc0e1463d3e33993a8681acd6b8f829a2ef9cf
parentd8ed17a5687b51c068760c5e4abc577c6a34c80e (diff)
parent916fb6a464390cd99ea87ee39f2406cc4b511787 (diff)
downloadrust-3636042664c9d5fade6a13079e0fe0ea19bd47df.tar.gz
rust-3636042664c9d5fade6a13079e0fe0ea19bd47df.zip
Rollup merge of #144650 - Borgerr:additional-tce-tests, r=WaffleLapkin,tgross35
Additional tce tests

r? `@oli-obk`

Adds known-bug tests for LLVM emissions regarding indirect operands for TCE. Also includes a test, `indexer.rs`, referring to function_table behavior described by the RFC.

Depends on rust-lang/rust#144232

Closes rust-lang/rust#144293
-rw-r--r--tests/crashes/144293-indirect-ops-llvm.rs42
-rw-r--r--tests/ui/explicit-tail-calls/drop-order.rs2
-rw-r--r--tests/ui/explicit-tail-calls/indexer.rs22
3 files changed, 64 insertions, 2 deletions
diff --git a/tests/crashes/144293-indirect-ops-llvm.rs b/tests/crashes/144293-indirect-ops-llvm.rs
new file mode 100644
index 00000000000..490a0116d7d
--- /dev/null
+++ b/tests/crashes/144293-indirect-ops-llvm.rs
@@ -0,0 +1,42 @@
+//@ known-bug: #144293
+// Same as recursion-etc but eggs LLVM emission into giving indirect arguments.
+#![expect(incomplete_features)]
+#![feature(explicit_tail_calls)]
+
+use std::hint::black_box;
+
+struct U64Wrapper {
+    pub x: u64,
+    pub arbitrary: String,
+}
+
+fn count(curr: U64Wrapper, top: U64Wrapper) -> U64Wrapper {
+    if black_box(curr.x) >= top.x {
+        curr
+    } else {
+        become count(
+            U64Wrapper {
+                x: curr.x + 1,
+                arbitrary: curr.arbitrary,
+            },
+            top,
+        )
+    }
+}
+
+fn main() {
+    println!(
+        "{}",
+        count(
+            U64Wrapper {
+                x: 0,
+                arbitrary: "hello!".into()
+            },
+            black_box(U64Wrapper {
+                x: 1000000,
+                arbitrary: "goodbye!".into()
+            })
+        )
+        .x
+    );
+}
diff --git a/tests/ui/explicit-tail-calls/drop-order.rs b/tests/ui/explicit-tail-calls/drop-order.rs
index 242336be484..58e1afbdf0c 100644
--- a/tests/ui/explicit-tail-calls/drop-order.rs
+++ b/tests/ui/explicit-tail-calls/drop-order.rs
@@ -1,5 +1,3 @@
-// FIXME(explicit_tail_calls): enable this test once rustc_codegen_ssa supports tail calls
-//@ ignore-test: tail calls are not implemented in rustc_codegen_ssa yet, so this causes 🧊
 //@ run-pass
 #![expect(incomplete_features)]
 #![feature(explicit_tail_calls)]
diff --git a/tests/ui/explicit-tail-calls/indexer.rs b/tests/ui/explicit-tail-calls/indexer.rs
new file mode 100644
index 00000000000..5644506b2f5
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/indexer.rs
@@ -0,0 +1,22 @@
+//@ run-pass
+// Indexing taken from
+// https://github.com/phi-go/rfcs/blob/guaranteed-tco/text%2F0000-explicit-tail-calls.md#tail-call-elimination
+// no other test has utilized the "function table"
+// described in the RFC aside from this one at this point.
+#![expect(incomplete_features)]
+#![feature(explicit_tail_calls)]
+
+fn f0(_: usize) {}
+fn f1(_: usize) {}
+fn f2(_: usize) {}
+
+fn indexer(idx: usize) {
+    let v: [fn(usize); 3] = [f0, f1, f2];
+    become v[idx](idx)
+}
+
+fn main() {
+    for idx in 0..3 {
+        indexer(idx);
+    }
+}