about summary refs log tree commit diff
path: root/tests/ui/explicit-tail-calls/indexer.rs
blob: c26d9774ce78011a00393329eb8ad99dedcf77c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//@ run-pass
//@ ignore-backends: gcc
// 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);
    }
}