You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 2023-10-11 consensus from lang on how to move forward included
that the `safe` and `unsafe` keywords would be optional within an
`unsafe extern` block.
The reference-level section correctly followed this consensus, but the
guide-level section did not, and suggested that annotating items with
these keywords was required. Let's fix that.
Copy file name to clipboardExpand all lines: text/0000-unsafe-extern-blocks.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ An `extern` block can be placed anywhere a function declaration could appear (ge
30
30
31
31
Within an `extern` block is zero or more declarations of external functions and/or external static values. An extern function is declared with a `;` instead of a function body (similar to a method of a trait). An extern static value is also declared with a `;` instead of an expression (similar to an associated const of a trait). In both cases, the actual function body or value is provided by whatever external source (which is probably not even written in Rust).
32
32
33
-
When an `unsafe extern` block is used, all declarations within that `extern` block *must* have the `unsafe` or `safe` keywords as part of their signature. The `safe` keyword is a contextual keyword; it is currently allowed only within `extern` blocks.
33
+
Declarations within an `unsafe extern` block *may* annotate their signatures with either `safe` or `unsafe`. If a signature within the block is not annotated, it is assumed to be `unsafe`. The `safe` keyword is contextual and is currently allowed only within `extern` blocks.
34
34
35
35
If an `extern` block is used in an older edition without the `unsafe` keyword, declarations *cannot* specify `safe` or `unsafe`. Code must update to `unsafe extern` style blocks if it wants to make `safe` declarations.
0 commit comments