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
The macro namespace is split into two sub-namespaces: one for [bang-style macros] and one for [attributes].
114
-
When an attribute is resolved, any bang-style macros in scope will be ignored.
115
-
And conversely resolving a bang-style macro will ignore attribute macros in scope.
113
+
The macro namespace is split into three sub-namespaces: [bang-style macros], [attributes], and [derives].
114
+
When a macro from one sub-namespace is resolved, any macros from other sub-namespaces in scope will be ignored.
116
115
This prevents one style from shadowing another.
117
116
118
117
For example, the [`cfg` attribute] and the [`cfg` macro] are two different entities with the same name in the macro namespace, but they can still be used in their respective context.
@@ -136,6 +135,7 @@ It is still an error for a [`use` import] to shadow another macro, regardless of
136
135
[Associated type declarations]: ../items/associated-items.md#associated-types
Copy file name to clipboardExpand all lines: src/procedural-macros.md
+4-3
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ These macros are defined by a [public] [function] with the `proc_macro`
94
94
output [`TokenStream`] replaces the entire macro invocation.
95
95
96
96
r[macro.proc.function.namespace]
97
-
The `proc_macro` attribute defines the macro in the [macro namespace] in the root of the crate.
97
+
The `proc_macro` attribute defines the macro in the [bang-style sub-namespace][sub-namespace] of the [macro namespace] in the root of the crate.
98
98
99
99
For example, the following macro definition ignores its input and outputs a
100
100
function `answer` into its scope.
@@ -144,7 +144,7 @@ Custom derive macros are defined by a [public] [function] with the
144
144
`proc_macro_derive` attribute and a signature of `(TokenStream) -> TokenStream`.
145
145
146
146
r[macro.proc.derive.namespace]
147
-
The `proc_macro_derive` attribute defines the custom derive in the [macro namespace] in the root of the crate.
147
+
The `proc_macro_derive` attribute defines the custom derive in the [derive sub-namespace][sub-namespace] of the [macro namespace] in the root of the crate.
148
148
149
149
r[macro.proc.derive.output]
150
150
The input [`TokenStream`] is the token stream of the item that has the `derive`
@@ -240,7 +240,7 @@ including other [attributes] on the [item]. The returned [`TokenStream`]
240
240
replaces the [item] with an arbitrary number of [items].
241
241
242
242
r[macro.proc.attribute.namespace]
243
-
The `proc_macro_attribute` attribute defines the attribute in the [macro namespace] in the root of the crate.
243
+
The `proc_macro_attribute` attribute defines the attribute in the [attribute sub-namespace][sub-namespace] of the [macro namespace] in the root of the crate.
244
244
245
245
For example, this attribute macro takes the input stream and returns it as is,
246
246
effectively being the no-op of attributes.
@@ -399,6 +399,7 @@ their equivalent `#[doc = r"str"]` attributes when passed to macros.
0 commit comments