Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
- [`gen` keyword](rust-2024/gen-keyword.md)
- [Macro fragment specifiers](rust-2024/macro-fragment-specifiers.md)
- [Never type fallback change](rust-2024/never-type-fallback.md)
- [`unsafe extern` blocks](rust-2024/unsafe-extern.md)
- [Unsafe `extern` blocks](rust-2024/unsafe-extern.md)
- [Unsafe attributes](rust-2024/unsafe-attributes.md)
6 changes: 2 additions & 4 deletions src/rust-2024/unsafe-extern.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `unsafe extern` blocks
# Unsafe `extern` blocks

🚧 The 2024 Edition has not yet been released and hence this section is still "under construction".
More information may be found in the tracking issue at <https://github.com/rust-lang/rust/issues/123743>.
Expand All @@ -11,13 +11,11 @@ More information may be found in the tracking issue at <https://github.com/rust-

## Details

Rust 1.xx <!--TODO--> added the ability in all editions to mark [`extern` blocks] with the `unsafe` keyword.[^RFC3484] Adding the `unsafe` keyword helps to emphasize that it is the responsibility of the author of the `extern` block to ensure that the signatures are correct. If the signatures are not correct, then it may result in undefined behavior.
Rust 1.82 added the ability in all editions to mark [`extern` blocks] with the `unsafe` keyword.[^RFC3484] Adding the `unsafe` keyword helps to emphasize that it is the responsibility of the author of the `extern` block to ensure that the signatures are correct. If the signatures are not correct, then it may result in undefined behavior.

The syntax for an unsafe `extern` block looks like this:

```rust
# #![feature(unsafe_extern_blocks)]

unsafe extern "C" {
// sqrt (from libm) may be called with any `f64`
pub safe fn sqrt(x: f64) -> f64;
Expand Down