aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-02-03 16:48:41 +0000
committerJonas Schievink <[email protected]>2021-02-03 16:54:03 +0000
commitd4a22fc801f4768990c7e62241bea5fe4ff92ead (patch)
tree699185021f8a379fb50707ec41e0cea286bc842d /crates/hir_def/src/nameres.rs
parentfd84df9e1bb231f7aa4bcf760e0aff0a6bd10e9f (diff)
Update `DefMap` and `block_def_map` docs
Diffstat (limited to 'crates/hir_def/src/nameres.rs')
-rw-r--r--crates/hir_def/src/nameres.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs
index ece5958f4..ef54f7d08 100644
--- a/crates/hir_def/src/nameres.rs
+++ b/crates/hir_def/src/nameres.rs
@@ -73,7 +73,15 @@ use crate::{
73 AstId, BlockId, BlockLoc, LocalModuleId, ModuleDefId, ModuleId, 73 AstId, BlockId, BlockLoc, LocalModuleId, ModuleDefId, ModuleId,
74}; 74};
75 75
76/// Contains all top-level defs from a macro-expanded crate 76/// Contains the results of (early) name resolution.
77///
78/// A `DefMap` stores the module tree and the definitions that are in scope in every module after
79/// item-level macros have been expanded.
80///
81/// Every crate has a primary `DefMap` whose root is the crate's main file (`main.rs`/`lib.rs`),
82/// computed by the `crate_def_map` query. Additionally, every block expression introduces the
83/// opportunity to write arbitrary item and module hierarchies, and thus gets its own `DefMap` that
84/// is computed by the `block_def_map` query.
77#[derive(Debug, PartialEq, Eq)] 85#[derive(Debug, PartialEq, Eq)]
78pub struct DefMap { 86pub struct DefMap {
79 _c: Count<Self>, 87 _c: Count<Self>,
@@ -91,6 +99,7 @@ pub struct DefMap {
91 diagnostics: Vec<DefDiagnostic>, 99 diagnostics: Vec<DefDiagnostic>,
92} 100}
93 101
102/// For `DefMap`s computed for a block expression, this stores its location in the parent map.
94#[derive(Debug, PartialEq, Eq)] 103#[derive(Debug, PartialEq, Eq)]
95struct BlockInfo { 104struct BlockInfo {
96 block: BlockId, 105 block: BlockId,