Skip to content

Commit c207931

Browse files
authored
Merge pull request #537 from ehuss/attribute-reorg-syntax
Reorg and update attributes
2 parents e97bb87 + 53c5cff commit c207931

28 files changed

+862
-564
lines changed

src/SUMMARY.md

+21-16
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,30 @@
2121

2222
- [Conditional compilation](conditional-compilation.md)
2323

24-
- [Items and attributes](items-and-attributes.md)
25-
- [Items](items.md)
26-
- [Modules](items/modules.md)
27-
- [Extern crates](items/extern-crates.md)
28-
- [Use declarations](items/use-declarations.md)
29-
- [Functions](items/functions.md)
30-
- [Type aliases](items/type-aliases.md)
31-
- [Structs](items/structs.md)
32-
- [Enumerations](items/enumerations.md)
33-
- [Unions](items/unions.md)
34-
- [Constant items](items/constant-items.md)
35-
- [Static items](items/static-items.md)
36-
- [Traits](items/traits.md)
37-
- [Implementations](items/implementations.md)
38-
- [External blocks](items/external-blocks.md)
24+
- [Items](items.md)
25+
- [Modules](items/modules.md)
26+
- [Extern crates](items/extern-crates.md)
27+
- [Use declarations](items/use-declarations.md)
28+
- [Functions](items/functions.md)
29+
- [Type aliases](items/type-aliases.md)
30+
- [Structs](items/structs.md)
31+
- [Enumerations](items/enumerations.md)
32+
- [Unions](items/unions.md)
33+
- [Constant items](items/constant-items.md)
34+
- [Static items](items/static-items.md)
35+
- [Traits](items/traits.md)
36+
- [Implementations](items/implementations.md)
37+
- [External blocks](items/external-blocks.md)
3938
- [Type and lifetime parameters](items/generics.md)
4039
- [Associated Items](items/associated-items.md)
4140
- [Visibility and Privacy](visibility-and-privacy.md)
42-
- [Attributes](attributes.md)
41+
42+
- [Attributes](attributes.md)
43+
- [Testing](attributes/testing.md)
44+
- [Derive](attributes/derive.md)
45+
- [Diagnostics](attributes/diagnostics.md)
46+
- [Code generation](attributes/codegen.md)
47+
- [Limits](attributes/limits.md)
4348

4449
- [Statements and expressions](statements-and-expressions.md)
4550
- [Statements](statements.md)

src/abi.md

+33
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,40 @@ $ nm -C foo.o
5656
0000000000000000 T foo::quux
5757
```
5858

59+
## The `no_mangle` attribute
60+
61+
The *`no_mangle` attribute* may be used on any [item] to disable standard
62+
symbol name mangling. The symbol for the item will be the identifier of the
63+
item's name.
64+
65+
## The `link_section` attribute
66+
67+
The *`link_section` attribute* specifies the section of the object file that a
68+
[function] or [static]'s content will be placed into. It uses the
69+
[_MetaNameValueStr_] syntax to specify the section name.
70+
71+
```rust,ignore
72+
#[no_mangle]
73+
#[link_section = ".example_section"]
74+
pub static VAR1: u32 = 1;
75+
```
76+
77+
## The `export_name` attribute
78+
79+
The *`export_name` attribute* specifies the name of the symbol that will be
80+
exported on a [function] or [static]. It uses the [_MetaNameValueStr_] syntax
81+
to specify the symbol name.
82+
83+
```rust,ignore
84+
#[export_name = "exported_symbol_name"]
85+
pub fn name_in_rust() { }
86+
```
87+
88+
[_MetaNameValueStr_]: attributes.html#meta-item-attribute-syntax
5989
[`static` items]: items/static-items.html
6090
[attribute]: attributes.html
6191
[extern functions]: items/functions.html#extern-functions
6292
[external blocks]: items/external-blocks.html
93+
[function]: items/functions.html
94+
[item]: items.html
95+
[static]: items/static-items.html

src/attributes-redirect.html

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script>
2+
(function() {
3+
var fragments = {
4+
"#cold-attribute": "codegen.html#the-cold-attribute",
5+
"#conditional-compilation": "conditional-compilation.html",
6+
"#deprecation": "diagnostics.html#the-deprecated-attribute",
7+
"#derive": "attributes/derive.html",
8+
"#documentation": "../rustdoc/the-doc-attribute.html",
9+
"#ffi-attributes": "attributes.html#built-in-attributes-index",
10+
"#inline-attribute": "codegen.html#the-inline-attribute",
11+
"#lint-check-attributes": "diagnostics.html#lint-check-attributes",
12+
"#macro-related-attributes": "attributes.html#built-in-attributes-index",
13+
"#miscellaneous-attributes": "attributes.html#built-in-attributes-index",
14+
"#must_use": "diagnostics.html#the-must_use-attribute",
15+
"#optimization-hints": "codegen.html#optimization-hints",
16+
"#path": "items/modules.html#the-path-attribute",
17+
"#preludes": "crates-and-source-files.html#preludes-and-no_std",
18+
"#testing": "testing.html",
19+
"#tool-lint-attributes": "diagnostics.html#tool-lint-attributes",
20+
"#crate-only-attributes": "attributes.html#built-in-attributes-index",
21+
};
22+
var target = fragments[window.location.hash];
23+
if (target) {
24+
var url = window.location.toString();
25+
var base = url.substring(0, url.lastIndexOf('/'));
26+
window.location.replace(base + "/" + target);
27+
}
28+
})();
29+
</script>

0 commit comments

Comments
 (0)