about summary refs log tree commit diff
path: root/tests/ui/explicit-tail-calls/callee_is_ref.rs
blob: 36bf9efb952248dba788cfc015464bd8473476a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//@ run-rustfix
#![feature(explicit_tail_calls)]
#![expect(incomplete_features)]

fn f() {}

fn g() {
    become (&f)() //~ error: tail calls can only be performed with function definitions or pointers
}

fn h() {
    let table = [f as fn()];
    if let Some(fun) = table.get(0) {
        become fun(); //~ error: tail calls can only be performed with function definitions or pointers
    }
}

fn i() {
    become Box::new(&mut &f)(); //~ error: tail calls can only be performed with function definitions or pointers
}

fn main() {
    g();
    h();
    i();
}