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/names/name-resolution.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,24 @@ r[names.resolution.expansion]
17
17
r[names.resolution.expansion.intro]
18
18
Expansion-time name resolution is the stage of name resolution necessary to complete macro expansion and fully generate a crate's AST. This stage requires the resolution of macro invocations and use declarations. Resolving use declarations is required to resolve [path-based scope] macro invocations. Resolving macro invocations is required in order to expand them.
19
19
20
-
After expansion-time name resolution, the AST must not contain any unexpanded macro invocations. Every macro invocation resolves to a valid definition that exists in the final AST or an external crate. The resolution of imports must be *stable*. After expansion, imports in the fully expanded AST must resolve to the same definition, regardless of the order in which macros are expanded. Once the crate has been fully expanded all speculative import resolutions are validated to ensure that no new ambiguities were introduced by macro expansion.
After expansion-time name resolution, the AST must not contain any unexpanded macro invocations. Every macro invocation resolves to a valid definition that exists in the final AST or an external crate.
22
+
23
+
```rust,compile_fail
24
+
fn main() {
25
+
foo!(); // ERROR: cannot find macro `foo` in this scope
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.
31
+
32
+
r[names.resolution.expansion.speculation]
33
+
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.
21
34
22
35
> [!NOTE]
23
36
>
24
-
> Due to the iterative nature of macro expansion, this causes so called time traveling ambiguities, such as when a glob import introduces an item that is ambiguous with its own base path.
37
+
> Due to the iterative nature of macro expansion, this causes so called time traveling ambiguities, such as when a macro or glob import introduces an item that is ambiguous with its own base path.
0 commit comments