add extern "custom"#2300
Draft
folkertdev wants to merge 1 commit into
Draft
Conversation
tgross35
reviewed
Jun 28, 2026
Contributor
There was a problem hiding this comment.
Maybe it would be good to have an example at src/inline-assembly.md alongside naked functions?
| For other considerations and limitations regarding unwinding across FFI boundaries, see the [relevant section in the Panic documentation][panic-ffi]. | ||
|
|
||
| r[items.fn.extern.custom] | ||
| An `extern "custom"` function has an unknown, custom ABI. The only way to call such a function is via [inline assembly]. |
Contributor
There was a problem hiding this comment.
Maybe a usage hint:
... unknown, custom ABI. This can be used to implement calling conventions unsupported by
rustc. The only way to call such a function is via [inline assembly].
tgross35
reviewed
Jun 28, 2026
Contributor
There was a problem hiding this comment.
Somewhere in the reference it would probably be good to clarify the purpose of parameters and return types in extern "custom" definitions, since they don't directly serve any purpose. I feel like we discussed this somewhere but can't seem to find it.
Contributor
Author
There was a problem hiding this comment.
We actually disallow them entirely
error: invalid signature for `extern "custom"` function
--> <source>:6:31
|
6 | unsafe extern "custom" fn foo(a: i32) -> i32 {
| ^^^^^^ ^^^
|
= note: functions with the "custom" ABI cannot have any parameters or return type
help: remove the parameters and return type
|
6 - unsafe extern "custom" fn foo(a: i32) -> i32 {
6 + unsafe extern "custom" fn foo() {
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stabilization PR: rust-lang/rust#158504
This is a tricky one that is an exception to some rules. I've tried to put the raw information in, but this'll probably require some refinement.