Skip to content

Commit 2afe85e

Browse files
authored
Fix abi chapter tests to comply with edition 2024
1 parent 1582d3f commit 2afe85e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/abi.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,21 @@ r[abi.symbol-name.names]
256256
The *`export_name` attribute* shall only be applied to a `static` or `fn` item. The *`export_name` attribute* shall not be applied to an item declared within an [`extern` block].
257257

258258
```rust
259-
#[no_mangle]
259+
#[unsafe(no_mangle(]
260260
extern "C" fn foo(x: i32) -> i32 {
261261
x + 1
262262
}
263263

264-
#[export_name = "bar"]
264+
#[unsafe(export_name = "bar")]
265265
extern "C" fn baz(x: i32) -> i32 {
266266
x + 2
267267
}
268268
```
269269

270270
```rust,compile_fail
271-
extern "C" {
272-
#[export_name = "foo"]
273-
fn __foo(x: i32) -> i32; // error: not a free function, impl method, or static
271+
unsafe extern "C" {
272+
#[unsafe(export_name = "foo")]
273+
unsafe fn __foo(x: i32) -> i32; // error: not a free function, impl method, or static
274274
}
275275
```
276276

@@ -284,11 +284,11 @@ r[abi.symbol-name.no_mangle]
284284
The *`no_mangle` attribute* may be specified as a built-in attribute, using the [_MetaWord_] syntax. The *export name* of an item with the *`no_mangle` attribute* is the declaration name of the item.
285285

286286
```rust
287-
extern "C" {
288-
fn bar() -> i32;
287+
unsafe extern "C" {
288+
unsafe fn bar() -> i32;
289289
}
290290
mod inner{
291-
#[no_mangle]
291+
#[unsafe(no_mangle)]
292292
extern "C" fn bar() -> i32 {
293293
0
294294
}
@@ -304,11 +304,11 @@ r[abi.symbol-name.export_name]
304304
The *`export_name` attribute* may be specified as a built-in attribute, using the [_MetaNameValueStr_] syntax. The *export name* of an item with the *`no_mangle` attribute* is the content of `STRING_LITERAL`.
305305

306306
```rust
307-
extern "C" {
308-
fn bar() -> i32;
307+
unsafe extern "C" {
308+
unsafe fn bar() -> i32;
309309
}
310310
mod inner{
311-
#[export_name = "bar"]
311+
#[unsafe(export_name = "bar")]
312312
extern "C" fn __some_other_item_name() -> i32 {
313313
0
314314
}

0 commit comments

Comments
 (0)