Skip to content

Commit 73c11ac

Browse files
committed
Use unsafe in the unsafe attribute examples.
This will be required in 2024.
1 parent f6cd69a commit 73c11ac

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/abi.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ object file, similar to the [`used` attribute](#the-used-attribute).
6969
This attribute is unsafe as an unmangled symbol may collide with another symbol
7070
with the same name (or with a well-known symbol), leading to undefined behavior.
7171

72+
```rust
73+
#[unsafe(no_mangle)]
74+
extern "C" fn foo() {}
75+
```
76+
7277
## The `link_section` attribute
7378

7479
The *`link_section` attribute* specifies the section of the object file that a
@@ -80,8 +85,8 @@ of memory not expecting them, such as mutable data into read-only areas.
8085

8186
<!-- no_run: don't link. The format of the section name is platform-specific. -->
8287
```rust,no_run
83-
#[no_mangle]
84-
#[link_section = ".example_section"]
88+
#[unsafe(no_mangle)]
89+
#[unsafe(link_section = ".example_section")]
8590
pub static VAR1: u32 = 1;
8691
```
8792

@@ -96,7 +101,7 @@ symbol with the same name (or with a well-known symbol), leading to undefined
96101
behavior.
97102

98103
```rust
99-
#[export_name = "exported_symbol_name"]
104+
#[unsafe(export_name = "exported_symbol_name")]
100105
pub fn name_in_rust() { }
101106
```
102107

0 commit comments

Comments
 (0)