document the interaction between macros and nameres
"The name resolution is a separate pass" is a wishful thinking :(
This commit is contained in:
parent
817a8879c9
commit
c5c2df2f87
|
|
@ -1,12 +1,17 @@
|
||||||
# Name resolution
|
# Name resolution
|
||||||
|
|
||||||
The name resolution is a separate pass in the compiler. Its input is the syntax
|
The name resolution is a two-phase process. In the first phase, which runs
|
||||||
tree, produced by parsing input files. It produces links from all the names in
|
during macro expansion, we build a tree of modules and resolve imports. Macro
|
||||||
the source to relevant places where the name was introduced. It also generates
|
expansion and name resolution communicate with each other via the `Resolver`
|
||||||
|
trait, defined in `libsyntax`.
|
||||||
|
|
||||||
|
The input to the second phase is the syntax tree, produced by parsing input
|
||||||
|
files and expanding macros. This phase produces links from all the names in the
|
||||||
|
source to relevant places where the name was introduced. It also generates
|
||||||
helpful error messages, like typo suggestions, traits to import or lints about
|
helpful error messages, like typo suggestions, traits to import or lints about
|
||||||
unused items.
|
unused items.
|
||||||
|
|
||||||
A successful run of the name resolution (`Resolver::resolve_crate`) creates kind
|
A successful run of the second phase (`Resolver::resolve_crate`) creates kind
|
||||||
of an index the rest of the compilation may use to ask about the present names
|
of an index the rest of the compilation may use to ask about the present names
|
||||||
(through the `hir::lowering::Resolver` interface).
|
(through the `hir::lowering::Resolver` interface).
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue