Skip to content

Commit 9fd5b4d

Browse files
committed
Update ABI.
- Address review comments. - Add links to other parts of the reference. - Remove "list of features", will move these attributes in a future PR. - Remove feature(used), not needed. - Remove `pub` from QUUX. Otherwise it is the same as BAZ. I believe this was trying to illustrate that a private static accessed from a public function counts as "used".
1 parent e47b299 commit 9fd5b4d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/abi.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Application Binary Interface (ABI)
22

3-
This section documents features that affect the ABI of a Rust program / binary, rlib, dylib, etc. A
4-
list of such features is shown below:
3+
This section documents features that affect the ABI of the compiled output of
4+
a crate.
55

6-
- `#[export_name]`
7-
- `#[link_section]`
8-
- `#[no_mangle]`
9-
- `#[used]`
10-
- `extern "$ABI" fn`
6+
See *[extern functions]* for information on specifying the ABI for exporting
7+
functions. See *[external blocks]* for information on specifying the ABI for
8+
linking external libraries.
119

12-
## `#[used]`
10+
## The `used` attribute
1311

14-
The `#[used]` attribute can only be applied to `static` variables. This attribute forces the
12+
The *`used` attribute* can only be applied to [`static` variables]. This [attribute] forces the
1513
compiler to keep the variable in the output object file (.o, .rlib, etc.) even if the variable is
1614
not used, or referenced, by any other item in the crate.
1715

@@ -21,26 +19,24 @@ output object file.
2119
``` rust
2220
// foo.rs
2321

24-
#![feature(used)]
25-
2622
// kept because of #[used]
2723
#[used]
2824
static FOO: u32 = 0;
2925

30-
// removed because it's unused
26+
// removable because it is unused
3127
#[allow(dead_code)]
3228
static BAR: u32 = 0;
3329

34-
// kept because it's referenced by a public, reachable function
30+
// kept because it is referenced by a public, reachable function
3531
pub static BAZ: u32 = 0;
3632

37-
pub static QUUX: u32 = 0;
33+
static QUUX: u32 = 0;
3834

3935
pub fn quux() -> &'static u32 {
4036
&QUUX
4137
}
4238

43-
// removed because it's referenced by a private, unused (dead) function
39+
// removable because it is referenced by a private, unused (dead) function
4440
static CORGE: u32 = 0;
4541

4642
#[allow(dead_code)]
@@ -58,3 +54,8 @@ $ nm -C foo.o
5854
0000000000000000 R foo::QUUX
5955
0000000000000000 T foo::quux
6056
```
57+
58+
[`static` variables]: items/static-items.html
59+
[attribute]: attributes.html
60+
[extern functions]: items/functions.html#extern-functions
61+
[external blocks]: items/external-blocks.html

0 commit comments

Comments
 (0)