Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/items/external-blocks.md
Comment thread
traviscross marked this conversation as resolved.
Comment thread
traviscross marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ r[items.extern.fn.param-patterns]
Patterns are not allowed in parameters, only [IDENTIFIER] or `_` may be used.

r[items.extern.fn.qualifiers]
The `safe` and `unsafe` function qualifiers are allowed, but other function qualifiers (e.g. `const`, `async`, `extern`) are not.
The `safe` and `unsafe` function qualifiers are allowed, but other function qualifiers (e.g. `const`, `async`, `extern`) are not. The `safe` qualifier is rejected in `extern "custom"` blocks.

r[items.extern.fn.foreign-abi]
Functions within external blocks may be called by Rust code, just like functions defined in Rust. The Rust compiler automatically translates between the Rust ABI and the foreign ABI.
Expand Down Expand Up @@ -112,6 +112,9 @@ r[items.extern.abi.system]
r[items.extern.abi.unwind]
* `extern "C-unwind"` and `extern "system-unwind"` --- Identical to `"C"` and `"system"`, respectively, but with [different behavior][unwind-behavior] when the callee unwinds (by panicking or throwing a C++ style exception).

r[items.extern.abi.custom]
* `unsafe extern "custom"` --- A custom ABI that is not known to the rust compiler.
Comment thread
folkertdev marked this conversation as resolved.
Outdated

r[items.extern.abi.platform]
There are also some platform-specific ABI strings:

Expand Down
11 changes: 11 additions & 0 deletions 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.

Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ With `panic=unwind`, when a `panic` is turned into an abort by a non-unwinding A

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].
Comment thread
traviscross marked this conversation as resolved.

r[items.fn.extern.custom.safety]
An `extern "custom"` function must be `unsafe`.

r[items.fn.extern.custom.naked]
An `extern "custom"` function definition must be a [naked function].

Comment thread
traviscross marked this conversation as resolved.
[forced-unwinding]: https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html#forced-unwinding
[panic handler]: ../panic.md#the-panic_handler-attribute
[panic-ffi]: ../panic.md#unwinding-across-ffi-boundaries
Expand Down Expand Up @@ -411,6 +420,7 @@ fn foo_oof(#[some_inert_attribute] arg: u8) {
[testing attributes]: ../attributes/testing.md
[`cold`]: ../attributes/codegen.md#the-cold-attribute
[`inline`]: ../attributes/codegen.md#the-inline-attribute
[naked function]: ../attributes/codegen.md#the-naked-attribute
[`deprecated`]: ../attributes/diagnostics.md#the-deprecated-attribute
[`doc`]: ../../rustdoc/the-doc-attribute.html
[`must_use`]: ../attributes/diagnostics.md#the-must_use-attribute
Expand All @@ -427,3 +437,4 @@ fn foo_oof(#[some_inert_attribute] arg: u8) {
[variadic function]: external-blocks.md#variadic-functions
[`extern` block]: external-blocks.md
[zero-sized]: glossary.zst
[inline assembly]: ../inline-assembly.md
Loading