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 resolution of names must be *stable*. After expansion, names in the fully expanded AST must resolve to the same definition, regardless of the order in which macros are expanded.
44
44
45
45
r[names.resolution.expansion.speculation]
46
-
All name resolution candidates selected during macro expansion are considering speculative. Once the crate has been fully expanded all speculative import resolutions are validated to ensure that no new ambiguities were introduced by macro expansion.
46
+
All name resolution candidates selected during macro expansion are considered speculative. Once the crate has been fully expanded, all speculative import resolutions are validated to ensure that macro expansion did not introduce any new ambiguities.
Some situations are an error when there is an ambiguity as to which macro definition, `use` declaration, or module an import or macro invocation's name refers to. This happens when there are two name candidates that do not resolve to the same entity where neither candidate is [permitted] to shadow the other.
Names may not be resolved through ambiguous glob imports. Glob imports are allowed to import conflicting names in the same namespace as long as the name is not used. Names with conflicting candidates from ambiguous glob imports may still be shadowed by non glob imports and used without producing an error. The errors occur at time of use, not time of import.
135
135
136
136
For example:
@@ -223,7 +223,7 @@ pub fn qux() {
223
223
```
224
224
225
225
> [!NOTE]
226
-
> These ambiguity errors are specific to imports, even though they are only observed when those imports are used, having multiple candidates available for a given name during later stages of resolution is not considered an error, so long as none of the imports themselves are ambiguous, there will always be a single unambiguous closest resolution during later stages.
226
+
> These ambiguity errors are specific to imports, even though they are only observed when those imports are used. Having multiple candidates available for a given name during later stages of resolution is not considered an error, so long as none of the imports themselves are ambiguous, there will always be a single unambiguous closest resolution.
227
227
>
228
228
> ```rust
229
229
> modbar {
@@ -333,10 +333,7 @@ The available scopes are visited in the following order.
333
333
334
334
> [!NOTE]
335
335
>
336
-
> The compiler will attempt to resolve derive helpers that are used before
337
-
> their associated macro introduces them into scope after resolving derive
338
-
> helper candidates that are correctly in scope. This behavior is slated for
339
-
> removal.
336
+
> The compiler will attempt to resolve derive helpers that are used before their associated macro introduces them into scope after resolving derive helper candidates that are correctly in scope. This behavior is slated for removal.
340
337
>
341
338
> For more info see [derive helper scope].
342
339
@@ -345,7 +342,7 @@ The available scopes are visited in the following order.
345
342
> Starting in edition 2018 the `#[macro_use]` prelude is not visited when `#[no_implicit_prelude]` is present.
Copy file name to clipboardExpand all lines: src/procedural-macros.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -241,12 +241,10 @@ A helper attribute for a derive macro is declared by adding its identifier to th
241
241
> ```
242
242
243
243
r[macro.proc.derive.attributes.scope]
244
-
Helper attributes are in scope after the macro that introduces them.
244
+
Helper attributes are in scope as name candidates for resolving the names of attributes that are attached to the same item lexically after the macro that introduces them.
245
245
246
246
> [!NOTE]
247
-
> rustc currently allows derive helpers to be used before the macro that
248
-
> introduces them. Such derive helpers used out of order may not shadow other
249
-
> attribute macros. This behavior is deprecated and slated for removal.
247
+
> rustc currently allows derive helpers to be used before the macro that introduces them. Such derive helpers used out of order may not shadow other attribute macros. This behavior is deprecated and slated for removal.
0 commit comments