File tree Expand file tree Collapse file tree 4 files changed +90
-2
lines changed
tests/ui/explicit-tail-calls Expand file tree Collapse file tree 4 files changed +90
-2
lines changed Original file line number Diff line number Diff line change 1
- // FIXME(explicit_tail_calls): enable this test once rustc_codegen_ssa supports tail calls
2
- //@ ignore-test: tail calls are not implemented in rustc_codegen_ssa yet, so this causes 🧊
3
1
//@ run-pass
4
2
#![ expect( incomplete_features) ]
5
3
#![ feature( explicit_tail_calls) ]
Original file line number Diff line number Diff line change
1
+ //@ run-pass
2
+ // Indexing taken from
3
+ // https://github.com/phi-go/rfcs/blob/guaranteed-tco/text%2F0000-explicit-tail-calls.md#tail-call-elimination
4
+ // no other test has utilized the "function table"
5
+ // described in the RFC aside from this one at this point.
6
+ #![ expect( incomplete_features) ]
7
+ #![ feature( explicit_tail_calls) ]
8
+
9
+ fn f0 ( _: usize ) { }
10
+ fn f1 ( _: usize ) { }
11
+ fn f2 ( _: usize ) { }
12
+
13
+ fn indexer ( idx : usize ) {
14
+ let v: [ fn ( usize ) ; 3 ] = [ f0, f1, f2] ;
15
+ become v[ idx] ( idx)
16
+ }
17
+
18
+ fn main ( ) {
19
+ for idx in 0 ..3 {
20
+ indexer ( idx) ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ //@ build-fail
2
+ //@ normalize-stderr: "note: .*\n\n" -> ""
3
+ //@ normalize-stderr: "thread 'rustc' panicked.*\n" -> ""
4
+ //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
5
+ //@ normalize-stderr: "/rustc-dev/[^:]+" -> "$COMPILER_DIR_REAL"
6
+ //@ rustc-env:RUST_BACKTRACE=0
7
+ //@ known-bug: #144293
8
+ //@ failure-status: 101
9
+ // Same as recursion-etc but eggs LLVM emission into giving indirect arguments.
10
+ #![ expect( incomplete_features) ]
11
+ #![ feature( explicit_tail_calls) ]
12
+
13
+ use std:: hint:: black_box;
14
+
15
+ struct U64Wrapper {
16
+ pub x : u64 ,
17
+ pub arbitrary : String ,
18
+ }
19
+
20
+ fn count ( curr : U64Wrapper , top : U64Wrapper ) -> U64Wrapper {
21
+ if black_box ( curr. x ) >= top. x {
22
+ curr
23
+ } else {
24
+ become count(
25
+ U64Wrapper {
26
+ x : curr. x + 1 ,
27
+ arbitrary : curr. arbitrary ,
28
+ } ,
29
+ top,
30
+ )
31
+ }
32
+ }
33
+
34
+ fn main ( ) {
35
+ println ! (
36
+ "{}" ,
37
+ count(
38
+ U64Wrapper {
39
+ x: 0 ,
40
+ arbitrary: "hello!" . into( )
41
+ } ,
42
+ black_box( U64Wrapper {
43
+ x: 1000000 ,
44
+ arbitrary: "goodbye!" . into( )
45
+ } )
46
+ )
47
+ . x
48
+ ) ;
49
+ }
Original file line number Diff line number Diff line change
1
+ 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
2
+ --> $DIR/recursion-etc-u64wrapper.rs:24:16
3
+ |
4
+ LL | become count(
5
+ | ________________^
6
+ LL | | U64Wrapper {
7
+ LL | | x: curr.x + 1,
8
+ LL | | arbitrary: curr.arbitrary,
9
+ LL | | },
10
+ LL | | top,
11
+ LL | | )
12
+ | |_________^
13
+
14
+
15
+ Box<dyn Any>
16
+ query stack during panic:
17
+ end of query stack
18
+ error: aborting due to 1 previous error
19
+
You can’t perform that action at this time.
0 commit comments