rust/tests/ui/explicit-tail-calls
Guillaume Gomez e941e73368
Rollup merge of #133607 - WaffleLapkin:tail-call-checks, r=compiler-errors
implement checks for tail calls

Quoting the [RFC draft](https://github.com/phi-go/rfcs/blob/guaranteed-tco/text/0000-explicit-tail-calls.md):

> The argument to become is a function (or method) call, that exactly matches the function signature and calling convention of the callee. The intent is to ensure a matching ABI. Note that lifetimes may differ as long as they pass borrow checking, see [below](https://github.com/phi-go/rfcs/blob/guaranteed-tco/text/0000-explicit-tail-calls.md#return-type-coercion) for specifics on the return type.

> Tail calling closures and tail calling from closures is not allowed. This is due to the high implementation effort, see below, this restriction can be lifted by a future RFC.

> Invocations of operators were considered as valid targets but were rejected on grounds of being too error-prone. In any case, these can still be called as methods.

> Tail calling [variadic functions](https://doc.rust-lang.org/beta/unstable-book/language-features/c-variadic.html) and tail calling from variadic functions is not allowed. As support for variadic function is stabilized on a per target level, support for tail-calls regarding variadic functions would need to follow a similar approach. To avoid this complexity and to minimize implementation effort for backends, this interaction is currently not allowed but support can be added with a future RFC.

-----

The checks are implemented as a query, similarly to `check_unsafety`.

The code is cherry-picked straight out of #112657 which was written more than a year ago, so I expect we might need to change some things ^^"
2024-12-05 23:47:10 +01:00
..
become-macro.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
become-operator.fixed use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
become-operator.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
become-operator.stderr implement checks for tail calls 2024-11-29 04:44:41 +01:00
become-outside.array.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
become-outside.constant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
become-outside.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
become-uncallable.fixed use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
become-uncallable.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
become-uncallable.stderr implement checks for tail calls 2024-11-29 04:44:41 +01:00
closure.fixed use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
closure.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
closure.stderr implement checks for tail calls 2024-11-29 04:44:41 +01:00
constck.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
constck.stderr Support tail calls in mir via TerminatorKind::TailCall 2024-07-07 17:11:04 +02:00
ctfe-arg-bad-borrow.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
ctfe-arg-bad-borrow.stderr Support tail calls in the interpreter 2024-07-07 17:11:05 +02:00
ctfe-arg-good-borrow.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
ctfe-arg-move.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
ctfe-collatz-multi-rec.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
ctfe-id-unlimited.return.stderr fix ICE when promoted has layout size overflow 2024-12-01 19:52:27 +01:00
ctfe-id-unlimited.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
ctfe-tail-call-panic.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
ctfe-tail-call-panic.stderr Support tail calls in the interpreter 2024-07-07 17:11:05 +02:00
drop-order.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
in-closure.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
in-closure.stderr implement checks for tail calls 2024-11-29 04:44:41 +01:00
return-lifetime-sub.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
return-mismatches.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
return-mismatches.stderr Support tail calls in mir via TerminatorKind::TailCall 2024-07-07 17:11:04 +02:00
signature-mismatch.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
signature-mismatch.stderr implement checks for tail calls 2024-11-29 04:44:41 +01:00
unsafeck.rs use expect(incomplete_feature) instead of allow in tail call tests 2024-11-29 04:44:41 +01:00
unsafeck.stderr Support tail calls in mir via TerminatorKind::TailCall 2024-07-07 17:11:04 +02:00