diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-06 12:33:37 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-09-06 12:33:37 +0100 |
commit | 007737a0e7dd2866e02a6398d8ee4aa7d5051d8c (patch) | |
tree | 832c18b90aee7315384326be537aeb415cb5c4e1 /crates/ra_hir/src/nameres.rs | |
parent | 2015e8b4d15c8be6c8fd735b0c08ccbbe24fb934 (diff) | |
parent | f477f2516a0fc5cf040f1f19608c0239a5ebf868 (diff) |
Merge #1779
1779: minor r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index dc2e2172b..fe90879b6 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -1,51 +1,51 @@ | |||
1 | /// This module implements import-resolution/macro expansion algorithm. | 1 | //! This module implements import-resolution/macro expansion algorithm. |
2 | /// | 2 | //! |
3 | /// The result of this module is `CrateDefMap`: a data structure which contains: | 3 | //! The result of this module is `CrateDefMap`: a data structure which contains: |
4 | /// | 4 | //! |
5 | /// * a tree of modules for the crate | 5 | //! * a tree of modules for the crate |
6 | /// * for each module, a set of items visible in the module (directly declared | 6 | //! * for each module, a set of items visible in the module (directly declared |
7 | /// or imported) | 7 | //! or imported) |
8 | /// | 8 | //! |
9 | /// Note that `CrateDefMap` contains fully macro expanded code. | 9 | //! Note that `CrateDefMap` contains fully macro expanded code. |
10 | /// | 10 | //! |
11 | /// Computing `CrateDefMap` can be partitioned into several logically | 11 | //! Computing `CrateDefMap` can be partitioned into several logically |
12 | /// independent "phases". The phases are mutually recursive though, there's no | 12 | //! independent "phases". The phases are mutually recursive though, there's no |
13 | /// strict ordering. | 13 | //! strict ordering. |
14 | /// | 14 | //! |
15 | /// ## Collecting RawItems | 15 | //! ## Collecting RawItems |
16 | /// | 16 | //! |
17 | /// This happens in the `raw` module, which parses a single source file into a | 17 | //! This happens in the `raw` module, which parses a single source file into a |
18 | /// set of top-level items. Nested imports are desugared to flat imports in | 18 | //! set of top-level items. Nested imports are desugared to flat imports in |
19 | /// this phase. Macro calls are represented as a triple of (Path, Option<Name>, | 19 | //! this phase. Macro calls are represented as a triple of (Path, Option<Name>, |
20 | /// TokenTree). | 20 | //! TokenTree). |
21 | /// | 21 | //! |
22 | /// ## Collecting Modules | 22 | //! ## Collecting Modules |
23 | /// | 23 | //! |
24 | /// This happens in the `collector` module. In this phase, we recursively walk | 24 | //! This happens in the `collector` module. In this phase, we recursively walk |
25 | /// tree of modules, collect raw items from submodules, populate module scopes | 25 | //! tree of modules, collect raw items from submodules, populate module scopes |
26 | /// with defined items (so, we assign item ids in this phase) and record the set | 26 | //! with defined items (so, we assign item ids in this phase) and record the set |
27 | /// of unresolved imports and macros. | 27 | //! of unresolved imports and macros. |
28 | /// | 28 | //! |
29 | /// While we walk tree of modules, we also record macro_rules definitions and | 29 | //! While we walk tree of modules, we also record macro_rules definitions and |
30 | /// expand calls to macro_rules defined macros. | 30 | //! expand calls to macro_rules defined macros. |
31 | /// | 31 | //! |
32 | /// ## Resolving Imports | 32 | //! ## Resolving Imports |
33 | /// | 33 | //! |
34 | /// We maintain a list of currently unresolved imports. On every iteration, we | 34 | //! We maintain a list of currently unresolved imports. On every iteration, we |
35 | /// try to resolve some imports from this list. If the import is resolved, we | 35 | //! try to resolve some imports from this list. If the import is resolved, we |
36 | /// record it, by adding an item to current module scope and, if necessary, by | 36 | //! record it, by adding an item to current module scope and, if necessary, by |
37 | /// recursively populating glob imports. | 37 | //! recursively populating glob imports. |
38 | /// | 38 | //! |
39 | /// ## Resolving Macros | 39 | //! ## Resolving Macros |
40 | /// | 40 | //! |
41 | /// macro_rules from the same crate use a global mutable namespace. We expand | 41 | //! macro_rules from the same crate use a global mutable namespace. We expand |
42 | /// them immediately, when we collect modules. | 42 | //! them immediately, when we collect modules. |
43 | /// | 43 | //! |
44 | /// Macros from other crates (including proc-macros) can be used with | 44 | //! Macros from other crates (including proc-macros) can be used with |
45 | /// `foo::bar!` syntax. We handle them similarly to imports. There's a list of | 45 | //! `foo::bar!` syntax. We handle them similarly to imports. There's a list of |
46 | /// unexpanded macros. On every iteration, we try to resolve each macro call | 46 | //! unexpanded macros. On every iteration, we try to resolve each macro call |
47 | /// path and, upon success, we run macro expansion and "collect module" phase | 47 | //! path and, upon success, we run macro expansion and "collect module" phase |
48 | /// on the result | 48 | //! on the result |
49 | 49 | ||
50 | mod per_ns; | 50 | mod per_ns; |
51 | mod raw; | 51 | mod raw; |