Skip to content

Commit 19802a4

Browse files
committed
Revise no_mangle attribute text
Let's revise this section editorially.
1 parent 479d753 commit 19802a4

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/abi.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ r[abi.no_mangle]
6565
## The `no_mangle` attribute
6666
6767
r[abi.no_mangle.intro]
68-
The *`no_mangle` attribute* may be used on functions and statics to disable standard symbol name mangling. The symbol for the item will be the identifier of the item's name.
68+
The *`no_mangle` [attribute]* disables the standard symbol name mangling on a [function] or [static]. The symbol for the item is the item's identifier.
6969
7070
> [!EXAMPLE]
7171
> ```rust
@@ -74,7 +74,7 @@ The *`no_mangle` attribute* may be used on functions and statics to disable stan
7474
> ```
7575
7676
r[abi.no_mangle.syntax]
77-
The `no_mangle` attribute uses the [MetaWord] syntax and thus does not take any inputs.
77+
The `no_mangle` attribute uses the [MetaWord] syntax.
7878
7979
r[abi.no_mangle.allowed-positions]
8080
The `no_mangle` attribute may only be applied to:
@@ -85,7 +85,7 @@ The `no_mangle` attribute may only be applied to:
8585
- [Trait impl functions][items.impl.trait]
8686
8787
> [!NOTE]
88-
> `rustc` currently warns in other positions, but this may be rejected in the future.
88+
> `rustc` lints against use in other positions. This may become an error in the future.
8989
9090
<!-- TODO: Currently it works on a trait function with a body, but generates a warning about being phased out. how do we document that?
9191
https://github.com/rust-lang/rust/pull/86492#issuecomment-885682960
@@ -94,32 +94,35 @@ https://github.com/rust-lang/rust/pull/86492#issuecomment-885682960
9494
<!-- TODO: should this clarify that external block items are already unmangled?, and thus the attribute does nothing? Currently it is "phased out" warning. -->
9595
9696
r[abi.no_mangle.closures]
97-
`no_mangle` may not be used with a [closure].
97+
The `no_mangle` attribute may not be used with a [closure].
9898
9999
r[abi.no_mangle.generics]
100-
`no_mangle` may not be used on an item with generic parameters.
100+
The `no_mangle` attribute may not be used on an item with generic parameters.
101101
102102
r[abi.no_mangle.duplicates]
103-
Only the first instance of `no_mangle` on an item is honored. Subsequent `no_mangle` attributes are ignored.
103+
Only the first use of `no_mangle` on an item has effect.
104104
105105
> [!NOTE]
106-
> `rustc` currently warns on subsequent duplicate `no_mangle` attributes.
106+
> `rustc` lints against any use following the first.
107107
108108
r[abi.no_mangle.export_name]
109-
If `no_mangle` is used with [`export_name`][abi.export_name], then the `export_name` is used instead.
109+
When the `no_mangle` and [`export_name`][abi.export_name] attributes are both applied to the same item, the symbol name from `export_name` is used, and `no_mangle` has no effect.
110+
111+
> [!NOTE]
112+
> `rustc` lints against this combination.
110113
111114
r[abi.no_mangle.unsafe]
112115
The `no_mangle` attribute must be marked with [`unsafe`][attributes.safety] because an unmangled symbol may collide with another symbol with the same name (or with a well-known symbol), leading to undefined behavior.
113116
114117
r[abi.no_mangle.edition2024]
115118
> [!EDITION-2024]
116-
> Before the 2024 edition it is allowed to use the `no_mangle` attribute without the `unsafe` qualification.
119+
> Before the 2024 edition, it is allowed to use the `no_mangle` attribute without `unsafe`.
117120
118121
r[abi.no_mangle.publicly-exported]
119-
In addition to disabling name mangling, the item will be publicly exported from the produced library or object file, similar to the [`used` attribute](#the-used-attribute).
122+
In addition to disabling name mangling, the `no_mangle` attribute causes the symbol to be publicly exported from the produced library or object file, similar to the [`used`][abi.used] attribute.
120123
121124
r[abi.no_mangle.ascii-only]
122-
`no_mangle` may only be used on items with a name that only contains ASCII characters.
125+
The `no_mangle` attribute may only be used on items with a name that contains only ASCII characters.
123126
124127
r[abi.link_section]
125128
## The `link_section` attribute

0 commit comments

Comments
 (0)