Skip to content

Commit 3fa1a61

Browse files
committed
corrections from Zulip feedback
1 parent 0637684 commit 3fa1a61

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

text/0000-unsafe-extern-blocks.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@ The up-side to this change is that in the new style it will be possible to decla
2323
Rust can utilize functions and statics from foreign code that are provided during linking, though it is `unsafe` to do so.
2424

2525
An `extern` block can be placed anywhere a function declaration could appear (generally at the top level of a module).
26-
* You can always write `unsafe extern { ... }`.
27-
* If the `unsafe_code` lint is denied or forbidden at a particular scope it will cause the `unsafe extern` block to be a compilation error within that scope.
28-
* On editions >= 2024, you must write all `extern` blocks as `unsafe extern`.
29-
* On editions < 2024, it is allowed to write an `extern` block *without* the `unsafe` keyword, but this generates a compatibility warning that you should use the `unsafe` keyword.
26+
27+
* On editions >= 2024, you *must* write all `extern` blocks as `unsafe extern`.
28+
* On editions < 2024, you *may* write `unsafe extern`, or you can write an `extern` block without the `unsafe` keyword. Writing an `extern` block without the `unsafe` keyword is provided for compatibility only, and will generate a warning.
29+
* `unsafe extern` interacts with the `unsafe_code` lint, and a `deny` or `forbid` with that lint will deny or forbid the unsafe external block.
3030

3131
Within an `extern` block is zero or more declarations of external functions and/or external static values.
3232
An extern function is declared with a `;` instead of a function body (similar to a method of a trait).
3333
An extern static value is also declared with a `;` instead of an expression (similar to an associated const of a trait).
3434
In both cases, the actual function body or value is provided by whatever external source (which is probably not even written in Rust).
3535

36-
When an `extern` block is used (with or without `unsafe` in front of it), all declarations within that `extern` block should have the `unsafe` or `safe` keywords as part of their signature.
37-
If one of the two keywords is not explicitly provided, the declaration is assumed to be `unsafe`.
38-
The `safe` keyword is a contextual keyword, only used within `extern` blocks.
36+
When an `unsafe extern` block is used, all declarations within that `extern` block *should* have the `unsafe` or `safe` keywords as part of their signature.
37+
If one of the two keywords is not explicitly provided, the declaration is assumed to be `unsafe`, and also a warning is generated.
38+
The `safe` keyword is a contextual keyword, it is currently only used within `extern` blocks.
39+
40+
If an `extern` block is used in an older edition without the `unsafe` keyword, declarations *cannot* specify `safe` or `unsafe`.
41+
Code must update to `unsafe extern` style blocks if it wants to make `safe` declarations.
3942

4043
```rust
4144
unsafe extern {

0 commit comments

Comments
 (0)