Skip to content

Additional tce tests #144650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions tests/ui/explicit-tail-calls/drop-order.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
22 changes: 22 additions & 0 deletions tests/ui/explicit-tail-calls/indexer.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
49 changes: 49 additions & 0 deletions tests/ui/explicit-tail-calls/recursion-etc-u64wrapper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//@ build-fail
//@ normalize-stderr: "note: .*\n\n" -> ""
//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> ""
//@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
//@ normalize-stderr: "/rustc-dev/[^:]+" -> "$COMPILER_DIR_REAL"
//@ rustc-env:RUST_BACKTRACE=0
//@ known-bug: #144293
//@ failure-status: 101
// 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
);
}
19 changes: 19 additions & 0 deletions tests/ui/explicit-tail-calls/recursion-etc-u64wrapper.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: internal compiler error: $COMPILER_DIR_REAL/rustc_codegen_ssa/src/mir/block.rs:LL:CC: arguments using PassMode::Indirect are currently not supported for tail calls
--> $DIR/recursion-etc-u64wrapper.rs:24:16
|
LL | become count(
| ________________^
LL | | U64Wrapper {
LL | | x: curr.x + 1,
LL | | arbitrary: curr.arbitrary,
LL | | },
LL | | top,
LL | | )
| |_________^


Box<dyn Any>
query stack during panic:
end of query stack
error: aborting due to 1 previous error

Loading