You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/attributes.md
+29-74Lines changed: 29 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,7 @@ AttrInput ->
17
17
```
18
18
19
19
r[attributes.intro]
20
-
An _attribute_ is a general, free-form metadatum that is interpreted according
21
-
to name, convention, language, and compiler version. Attributes are modeled
22
-
on Attributes in [ECMA-335], with the syntax coming from [ECMA-334]\(C#).
20
+
An _attribute_ is a general, free-form metadatum that is interpreted according to name, convention, language, and compiler version. Attributes are modeled on Attributes in [ECMA-335], with the syntax coming from [ECMA-334]\(C#).
23
21
24
22
r[attributes.inner]
25
23
_Inner attributes_, written with a bang (`!`) after the hash (`#`), apply to the form that the attribute is declared within.
@@ -62,17 +60,10 @@ _Outer attributes_, written without the bang after the hash, apply to the form t
Expressions in meta items must macro-expand to literal expressions, which must not
136
-
include integer or float type suffixes. Expressions which are not literal expressions
137
-
will be syntactically accepted (and can be passed to proc-macros), but will be rejected after parsing.
118
+
Expressions in meta items must macro-expand to literal expressions, which must not include integer or float type suffixes. Expressions which are not literal expressions will be syntactically accepted (and can be passed to proc-macros), but will be rejected after parsing.
138
119
139
120
r[attributes.meta.order]
140
-
Note that if the attribute appears within another macro, it will be expanded
141
-
after that outer macro. For example, the following code will expand the
142
-
`Serialize` proc-macro first, which must preserve the `include_str!` call in
143
-
order for it to be expanded:
121
+
Note that if the attribute appears within another macro, it will be expanded after that outer macro. For example, the following code will expand the `Serialize` proc-macro first, which must preserve the `include_str!` call in order for it to be expanded:
144
122
145
123
```rust ignore
146
124
#[derive(Serialize)]
@@ -162,9 +140,7 @@ fn foo() {}
162
140
```
163
141
164
142
r[attributes.meta.builtin]
165
-
Various built-in attributes use different subsets of the meta item syntax to
166
-
specify their inputs. The following grammar rules show some commonly used
167
-
forms:
143
+
Various built-in attributes use different subsets of the meta item syntax to specify their inputs. The following grammar rules show some commonly used forms:
168
144
169
145
r[attributes.meta.builtin.syntax]
170
146
```grammar,attributes
@@ -198,30 +174,21 @@ r[attributes.activity]
198
174
## Active and inert attributes
199
175
200
176
r[attributes.activity.intro]
201
-
An attribute is either active or inert. During attribute processing, *active
202
-
attributes* remove themselves from the form they are on while *inert attributes*
203
-
stay on.
177
+
An attribute is either active or inert. During attribute processing, *active attributes* remove themselves from the form they are on while *inert attributes* stay on.
204
178
205
-
The [`cfg`] and [`cfg_attr`] attributes are active.
206
-
[Attribute macros] are active. All other attributes are inert.
179
+
The [`cfg`] and [`cfg_attr`] attributes are active. [Attribute macros] are active. All other attributes are inert.
207
180
208
181
r[attributes.tool]
209
182
## Tool attributes
210
183
211
184
r[attributes.tool.intro]
212
-
The compiler may allow attributes for external tools where each tool resides
213
-
in its own module in the [tool prelude]. The first segment of the attribute
214
-
path is the name of the tool, with one or more additional segments whose
215
-
interpretation is up to the tool.
185
+
The compiler may allow attributes for external tools where each tool resides in its own module in the [tool prelude]. The first segment of the attribute path is the name of the tool, with one or more additional segments whose interpretation is up to the tool.
216
186
217
187
r[attributes.tool.ignored]
218
-
When a tool is not in use, the tool's attributes are accepted without a
219
-
warning. When the tool is in use, the tool is responsible for processing and
220
-
interpretation of its attributes.
188
+
When a tool is not in use, the tool's attributes are accepted without a warning. When the tool is in use, the tool is responsible for processing and interpretation of its attributes.
221
189
222
190
r[attributes.tool.prelude]
223
-
Tool attributes are not available if the [`no_implicit_prelude`] attribute is
224
-
used.
191
+
Tool attributes are not available if the [`no_implicit_prelude`] attribute is used.
225
192
226
193
```rust
227
194
// Tells the rustfmt tool to not format the following element.
@@ -253,13 +220,11 @@ The following is an index of all built-in attributes.
253
220
254
221
- Derive
255
222
-[`derive`] --- Automatic trait implementations.
256
-
-[`automatically_derived`] --- Marker for implementations created by
257
-
`derive`.
223
+
-[`automatically_derived`] --- Marker for implementations created by `derive`.
258
224
259
225
- Macros
260
226
-[`macro_export`] --- Exports a `macro_rules` macro for cross-crate usage.
261
-
-[`macro_use`] --- Expands macro visibility, or imports macros from other
262
-
crates.
227
+
-[`macro_use`] --- Expands macro visibility, or imports macros from other crates.
263
228
-[`proc_macro`] --- Defines a function-like macro.
264
229
-[`proc_macro_derive`] --- Defines a derive macro.
265
230
-[`proc_macro_attribute`] --- Defines an attribute macro.
@@ -268,27 +233,21 @@ The following is an index of all built-in attributes.
0 commit comments