Skip to content

Add extern "custom" - #2300

Open
folkertdev wants to merge 8 commits into
rust-lang:masterfrom
folkertdev:extern-custom
Open

Add extern "custom"#2300
folkertdev wants to merge 8 commits into
rust-lang:masterfrom
folkertdev:extern-custom

Conversation

@folkertdev

Copy link
Copy Markdown
Contributor

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.

Comment thread src/items/external-blocks.md
Comment thread src/items/functions.md
Comment thread src/items/external-blocks.md
@ehuss ehuss added the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Jul 28, 2026
Comment thread src/items/external-blocks.md Outdated
Comment thread src/items/functions.md
@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Jul 28, 2026
@rustbot

rustbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

folkertdev and others added 4 commits July 29, 2026 13:57
Co-authored-by: Travis Cross <tc@traviscross.com>
The `extern "custom"` rules were falling under the *Unwinding*
section.  Let's fix that.
This had said that an `extern "custom"` function *does* not have any
parameters, but it's clearer to say it *must* not have any parameters.
Comment thread src/items/functions.md Outdated
@traviscross
traviscross force-pushed the extern-custom branch 2 times, most recently from ac3a0e7 to 8752db9 Compare August 4, 2026 21:32
On the lang side, we decided the signature rules for `extern "custom"`
function pointers should match those for `extern "custom"` function
items.  Let's consolidate the signature rules on function items into a
single rule then cite that rule normatively from the function pointer
types chapter.
@traviscross traviscross removed the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Aug 4, 2026
@traviscross
traviscross marked this pull request as ready for review August 4, 2026 21:39
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 4, 2026
@traviscross traviscross changed the title add extern "custom" Add extern "custom" Aug 4, 2026
@traviscross traviscross removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 4, 2026
In review, it was suggested that we add an example showing how
`extern "custom"` functions are used in practice.  Let's do that.
Often naked functions should use `extern "custom"`.  Let's add an
admonition to note that.
Comment thread src/items/functions.md
Comment on lines +284 to +286
- Be `unsafe`.
- Not have any parameters.
- Return the [unit type].

@tgross35 tgross35 Aug 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some consideration for generics, rust-lang/rust#158504 (comment) and the comment below

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that generics are probably okay and allowed by default if not disallowed?

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things that I think should be resolved before merge

View changes since this review

Comment thread src/items/functions.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking through the list at https://doc.rust-lang.org/reference/items/functions.html#attributes-on-functions, also noticed that #[cold] may make no sense. Everything else seems fine

rust-lang/rust#158504 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't do harm either, so should we really make an exception here? I'm not against it per se, just wondering if we should make this calling convention even more special.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants