@@ -115,11 +115,13 @@ As non-Rust calling conventions do not support unwinding, unwinding past the end
115
115
of an extern function will cause the process to abort. In LLVM, this is
116
116
implemented by executing an illegal instruction.
117
117
118
- ## Function attributes
118
+ ## Attributes on functions
119
119
120
- Inner [ attributes] on the function's block apply to the function item as a whole.
120
+ [ Outer attributes] [ attributes ] are allowed on functions. [ Inner
121
+ attributes] [ attributes ] are allowed directly after the ` { ` inside its [ block] .
121
122
122
- For example, this function will only be available while running tests.
123
+ This example shows an inner attribute on a function. The function will only be
124
+ available while running tests.
123
125
124
126
```
125
127
fn test_only() {
@@ -130,6 +132,11 @@ fn test_only() {
130
132
> Note: Except for lints, it is idiomatic to only use outer attributes on
131
133
> function items.
132
134
135
+ The attributes that have meaning on a function are [ ` cfg ` ] , [ ` deprecated ` ] ,
136
+ [ ` doc ` ] , ` export_name ` , ` link_section ` , ` no_mangle ` , [ the lint check
137
+ attributes] , [ ` must_use ` ] , [ the testing attributes] , and [ the optimization hint
138
+ attributes] .
139
+
133
140
[ external blocks ] : items/external-blocks.html
134
141
[ path ] : paths.html
135
142
[ block ] : expressions/block-expr.html
@@ -138,3 +145,10 @@ fn test_only() {
138
145
[ *function item type* ] : types.html#function-item-types
139
146
[ Trait ] : items/traits.html
140
147
[ attributes ] : attributes.html
148
+ [ `cfg` ] : conditional-compilation.html
149
+ [ the lint check attributes ] : attributes.html#lint-check-attributes
150
+ [ the testing attributes ] : attributes.html#testing
151
+ [ the optimization hint attributes ] : attributes.html#optimization-hints
152
+ [ `deprecated` ] : attributes.html#deprecation
153
+ [ `doc` ] : attributes.html#documentation
154
+ [ `must_use` ] : attributes.html#must_use
0 commit comments