Skip to content

Commit 6247a2e

Browse files
Rollup merge of rust-lang#158374 - WaffleLapkin:no-tail-rust-call, r=folkertdev
disallow tail calling extern "rust-call" functions r? folkertdev Following discussion from rust-lang#158248. Fixes rust-lang#158017 Closes rust-lang#158248
2 parents cd7d007 + 4594bcf commit 6247a2e

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

compiler/rustc_abi/src/extern_abi.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,16 @@ impl ExternAbi {
343343
// This ABI does not support calls at all (except via assembly).
344344
false
345345
}
346+
Self::RustCall => {
347+
// Argument untupling requires additional support for tail calls to be possible,
348+
// see <https://github.com/rust-lang/rust/pull/158248>. There is no real uses of
349+
// tail calling `extern "rust-call"` functions
350+
false
351+
}
352+
346353
Self::C { .. }
347354
| Self::System { .. }
348355
| Self::Rust
349-
| Self::RustCall
350356
| Self::RustCold
351357
| Self::RustInvalid
352358
| Self::Unadjusted
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// extern "rust-call" untuples the first (and only, except self) argument, this requires additional
2+
// support for tail calls to work correctly. Since there doesn't seem to be a usecase for tail
3+
// calling extern "rust-call" functions (extern "rust-call" only shows up in closures, which we
4+
// disallow tail-calling anyway), we just disallow that.
5+
//
6+
// @ ignore-backends: gcc
7+
#![expect(incomplete_features)]
8+
#![feature(explicit_tail_calls)]
9+
#![feature(unboxed_closures)]
10+
11+
extern "rust-call" fn a(_: ()) {
12+
become a(());
13+
//~^ error: ABI does not support guaranteed tail calls
14+
}
15+
16+
fn main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: ABI does not support guaranteed tail calls
2+
--> $DIR/rust-call.rs:12:5
3+
|
4+
LL | become a(());
5+
| ^^^^^^^^^^^^
6+
|
7+
= note: `become` is not supported for `extern "rust-call"` functions
8+
9+
error: aborting due to 1 previous error
10+

0 commit comments

Comments
 (0)