document the interaction between macros and nameres

"The name resolution is a separate pass" is a wishful thinking :(
This commit is contained in:
Aleksey Kladov 2018-11-08 16:46:39 +03:00 committed by Who? Me?!
parent 817a8879c9
commit c5c2df2f87
1 changed files with 9 additions and 4 deletions

View File

@ -1,12 +1,17 @@
# Name resolution
The name resolution is a separate pass in the compiler. Its input is the syntax
tree, produced by parsing input files. It produces links from all the names in
the source to relevant places where the name was introduced. It also generates
The name resolution is a two-phase process. In the first phase, which runs
during macro expansion, we build a tree of modules and resolve imports. Macro
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
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
(through the `hir::lowering::Resolver` interface).