Skip to content

Commit c1e2bbd

Browse files
committed
Clarify naked function calling convention reqs
Although we don't have `extern "custom"` anymore, `unsafe` can pragmatically fill this roll. Marking a function as `unsafe` implies that the function cannot be safely called unless additional criteria are met (as documented in the safety section, per standard convention). This wording clarifies the RFC to point to this well-established convention.
1 parent 7a02895 commit c1e2bbd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

text/2972-constrained-naked.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A naked function is identified by the `#[naked]` attribute and:
2727
1. must not contain any operands except `const` or `sym`.
2828
1. must contain the `noreturn` option.
2929
1. must not contain any other options except `att_syntax`.
30-
1. must ensure that the requirements of the calling convention are followed.
30+
1. must ensure that the calling convention is followed or the function is `unsafe`.
3131

3232
In exchange for the above constraints, the compiler commits to:
3333
1. produce a clear error if any of the above requirements are violated.
@@ -126,6 +126,6 @@ All outstanding questions have been resolved.
126126

127127
It would be possible to define new calling conventions that can be used with naked functions.
128128

129-
A previous version of this document defined an `extern "custom"` calling convention. It was observed in conversation that calling conventions are really a *type* and that it could be useful to have calling conventions as part of the type system. In the interest of moving forward with constrained naked functions, it is best to limit the scope of this RFC and defer this (very good) conversation to a future RFC.
129+
A previous version of this document defined an `extern "custom"` calling convention. It was observed in conversation that calling conventions are really a *type* and that it could be useful to have calling conventions as part of the type system. In the interest of moving forward with constrained naked functions, it is best to limit the scope of this RFC and defer this (very good) conversation to a future RFC. As a simple workaround, naked functions which do not conform to their specified calling convention should be marked as unsafe and the caller requirements should be documented in the safety section of the documentation per standard convention.
130130

131131
It may also be possible to loosen the definition of a naked function in a future RFC. For example, it might be possible to allow the use of some additional, possibly new, operands to the `asm!()` block.

0 commit comments

Comments
 (0)