Skip to content

Commit

Permalink
Remove 2024 unsafe extern block notes
Browse files Browse the repository at this point in the history
These will be added back when 2024 stabilizes.
  • Loading branch information
ehuss committed Aug 9, 2024
1 parent a1a6f29 commit 875b905
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
9 changes: 1 addition & 8 deletions src/items/external-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> **<sup>Syntax</sup>**\
> _ExternBlock_ :\
> &nbsp;&nbsp; `unsafe`<sup>?</sup>[^unsafe-2024] `extern` [_Abi_]<sup>?</sup> `{`\
> &nbsp;&nbsp; `unsafe`<sup>?</sup> `extern` [_Abi_]<sup>?</sup> `{`\
> &nbsp;&nbsp; &nbsp;&nbsp; [_InnerAttribute_]<sup>\*</sup>\
> &nbsp;&nbsp; &nbsp;&nbsp; _ExternalItem_<sup>\*</sup>\
> &nbsp;&nbsp; `}`
Expand All @@ -12,8 +12,6 @@
> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; [_MacroInvocationSemi_]\
> &nbsp;&nbsp; &nbsp;&nbsp; | ( [_Visibility_]<sup>?</sup> ( [_StaticItem_] | [_Function_] ) )\
> &nbsp;&nbsp; )
>
> [^unsafe-2024]: Starting with the 2024 Edition, the `unsafe` keyword is required semantically.
External blocks provide _declarations_ of items that are not _defined_ in the
current crate and are the basis of Rust's foreign function interface. These are
Expand All @@ -25,11 +23,6 @@ blocks is only allowed in an `unsafe` context.

The external block defines its functions and statics in the [value namespace] of the module or block where it is located.

**Edition differences**: Starting in the 2024 edition, the `unsafe` keyword is
required to appear before the `extern` keyword on external blocks. In previous
editions, it is accepted but not required. The `safe` and `unsafe` item qualifiers
are only allowed if the external block itself is marked as `unsafe`.

## Functions

Functions within external blocks are declared in the same way as other Rust
Expand Down
6 changes: 1 addition & 5 deletions src/items/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
> &nbsp;&nbsp; &nbsp;&nbsp; ( [_BlockExpression_] | `;` )
>
> _FunctionQualifiers_ :\
> &nbsp;&nbsp; `const`<sup>?</sup> `async`[^async-edition]<sup>?</sup> _ItemSafety_<sup>?</sup>[^extern-qualifiers] (`extern` _Abi_<sup>?</sup>)<sup>?</sup>
> &nbsp;&nbsp; `const`<sup>?</sup> `async`[^async-edition]<sup>?</sup> _ItemSafety_<sup>?</sup> (`extern` _Abi_<sup>?</sup>)<sup>?</sup>
>
> _ItemSafety_ :\
> &nbsp;&nbsp; `safe`[^extern-safe] | `unsafe`
Expand Down Expand Up @@ -45,10 +45,6 @@
> [^extern-safe]: The `safe` function qualifier is only allowed semantically within
> `extern` blocks.
>
> [^extern-qualifiers]: *Relevant to editions earlier than Rust 2024*: Within
> `extern` blocks, the `safe` or `unsafe` function qualifier is only allowed
> when the `extern` is qualified as `unsafe`.
>
> [^fn-param-2015]: Function parameters with only a type are only allowed
> in an associated function of a [trait item] in the 2015 edition.
Expand Down
2 changes: 0 additions & 2 deletions src/unsafe-keyword.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,4 @@ Unsafe trait implementations are the logical dual to unsafe traits: where unsafe

The programmer who declares an [external block] must assure that the signatures of the items contained within are correct. Failing to do so may lead to undefined behavior. That this obligation has been met is indicated by writing `unsafe extern`.

**Edition differences**: Prior to edition 2024, `extern` blocks were allowed without being qualified as `unsafe`.

[external block]: items/external-blocks.md
4 changes: 1 addition & 3 deletions src/unsafety.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ Rust:
- Accessing a field of a [`union`], other than to assign to it.
- Calling an unsafe function (including an intrinsic or foreign function).
- Implementing an [unsafe trait].
- Declaring an [`extern`] block[^extern-2024].

[^extern-2024]: Prior to the 2024 edition, extern blocks were allowed to be declared without `unsafe`.
- Declaring an [`extern`] block.

[`extern`]: items/external-blocks.md
[`union`]: items/unions.md
Expand Down

0 comments on commit 875b905

Please sign in to comment.