Skip to content

Commit 7ee16d9

Browse files
authored
Merge pull request #530 from ehuss/derive-mode-macro-rename
Remove "mode" from derive macro terminology.
2 parents c3dd948 + 1bd25ee commit 7ee16d9

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/attributes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ There are three kinds of attributes:
9191

9292
* Built-in attributes
9393
* Macro attributes
94-
* Derive mode helper attributes
94+
* Derive macro helper attributes
9595

9696
## Active and inert attributes
9797

@@ -184,7 +184,7 @@ which can be used to control type layout.
184184

185185
- `proc_macro` - Defines a [function-like macro].
186186

187-
- `proc_macro_derive` - Defines a [derive mode macro].
187+
- `proc_macro_derive` - Defines a [derive macro].
188188

189189
- `proc_macro_attribute` - Defines an [attribute macro].
190190

@@ -587,7 +587,7 @@ You can implement `derive` for your own traits through [procedural macros].
587587
[attribute macro]: procedural-macros.html#attribute-macros
588588
[function-like macro]: procedural-macros.html#function-like-procedural-macros
589589
[conditional compilation]: conditional-compilation.html
590-
[derive mode macro]: procedural-macros.html#derive-mode-macros
590+
[derive macro]: procedural-macros.html#derive-macros
591591
[trait]: items/traits.html
592592
[main]: crates-and-source-files.html
593593
[`Termination`]: ../std/process/trait.Termination.html

src/procedural-macros.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Procedural macros come in one of three flavors:
55

66
* [Function-like macros] - `custom!(...)`
7-
* [Derive mode macros] - `#[derive(CustomMode)]`
7+
* [Derive macros] - `#[derive(CustomDerive)]`
88
* [Attribute macros] - `#[CustomAttribute]`
99

1010
Procedural macros allow you to run code at compile time that operates over Rust
@@ -111,21 +111,21 @@ with curly braces and no semicolon or a different delimiter followed by a
111111
semicolon. For example, `make_answer` from the previous example can be invoked
112112
as `make_answer!{}`, `make_answer!();` or `make_answer![];`.
113113

114-
### Derive mode macros
114+
### Derive macros
115115

116-
*Derive mode macros* define new modes for the `derive` [attribute]. These macros
117-
define new [items] given the token stream of a [struct], [enum], or [union].
118-
They also define [derive mode helper attributes].
116+
*Derive macros* define new inputs for the `derive` [attribute]. These macros
117+
can create new [items] given the token stream of a [struct], [enum], or [union].
118+
They can also define [derive macro helper attributes].
119119

120-
Custom deriver modes are defined by a [public] [function] with the
120+
Custom derive macros are defined by a [public] [function] with the
121121
`proc_macro_derive` attribute and a signature of `(TokenStream) -> TokenStream`.
122122

123123
The input [`TokenStream`] is the token stream of the item that has the `derive`
124124
attribute on it. The output [`TokenStream`] must be a set of items that are
125125
then appended to the [module] or [block] that the item from the input
126126
[`TokenStream`] is in.
127127

128-
The following is an example of a derive mode macro. Instead of doing anything
128+
The following is an example of a derive macro. Instead of doing anything
129129
useful with its input, it just appends a function `answer`.
130130

131131
```rust,ignore
@@ -138,7 +138,7 @@ pub fn derive_answer_fn(_item: TokenStream) -> TokenStream {
138138
}
139139
```
140140

141-
And then using said derive mode:
141+
And then using said derive macro:
142142

143143
```rust,ignore
144144
extern crate proc_macro_examples;
@@ -152,18 +152,18 @@ fn main() {
152152
}
153153
```
154154

155-
#### Derive mode helper attributes
155+
#### Derive macro helper attributes
156156

157-
Derive mode macros can add additional [attributes] into the scope of the [item]
158-
they are on. Said attributes are called *derive mode helper attributes*. These
157+
Derive macros can add additional [attributes] into the scope of the [item]
158+
they are on. Said attributes are called *derive macro helper attributes*. These
159159
attributes are [inert], and their only purpose is to be fed into the derive
160-
mode macro that defined them. That said, they can be seen by all macros.
160+
macro that defined them. That said, they can be seen by all macros.
161161

162162
The way to define helper attributes is to put an `attributes` key in the
163163
`proc_macro_derive` macro with a comma separated list of identifiers that are
164164
the names of the helper attributes.
165165

166-
For example, the following derive mode macro defines a helper attribute
166+
For example, the following derive macro defines a helper attribute
167167
`helper`, but ultimately doesn't do anything with it.
168168

169169
```rust,ignore
@@ -177,7 +177,7 @@ pub fn derive_helper_attr(_item: TokenStream) -> TokenStream {
177177
}
178178
```
179179

180-
And then usage on the derive mode on a struct:
180+
And then usage on the derive macro on a struct:
181181

182182
```rust,ignore
183183
# #![crate_type="proc-macro"]
@@ -272,15 +272,15 @@ fn invoke4() {}
272272
[`derive`]: attributes.html#derive
273273
[`proc_macro` crate]: ../proc_macro/index.html
274274
[Cargo's build scripts]: ../cargo/reference/build-scripts.html
275-
[Derive mode macros]: #derive-mode-macros
275+
[Derive macros]: #derive-macros
276276
[Attribute macros]: #attribute-macros
277277
[Function-like macros]: #function-like-procedural-macros
278278
[attribute]: attributes.html
279279
[attributes]: attributes.html
280280
[block]: expressions/block-expr.html
281281
[custom attributes]: attributes.html
282282
[crate type]: linkage.html
283-
[derive mode helper attributes]: #derive-mode-helper-attributes
283+
[derive macro helper attributes]: #derive-macro-helper-attributes
284284
[enum]: items/enumerations.html
285285
[inert]: attributes.html#active-and-inert-attributes
286286
[item]: items.html

0 commit comments

Comments
 (0)