Skip to content

Commit 870b021

Browse files
committed
Functions - Mention where inner attributes are allowed
1 parent a4dcd1f commit 870b021

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/items/functions.md

+16
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,26 @@ As non-Rust calling conventions do not support unwinding, unwinding past the end
115115
of an extern function will cause the process to abort. In LLVM, this is
116116
implemented by executing an illegal instruction.
117117

118+
## Function attributes
119+
120+
Inner [attributes] on the function's block apply to the function item as a whole.
121+
122+
For example, this function will only be available while running tests.
123+
124+
```
125+
fn test_only() {
126+
#![test]
127+
}
128+
```
129+
130+
> Note: Except for lints, it is idiomatic to only use outer attributes on
131+
> function items.
132+
118133
[external blocks]: items/external-blocks.html
119134
[path]: paths.html
120135
[block]: expressions/block-expr.html
121136
[variables]: variables.html
122137
[type]: types.html
123138
[*function item type*]: types.html#function-item-types
124139
[Trait]: items/traits.html
140+
[attributes]: attributes.html

0 commit comments

Comments
 (0)