aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/lib.rs')
-rw-r--r--crates/hir_def/src/lib.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs
index 6758411a0..c9e07de86 100644
--- a/crates/hir_def/src/lib.rs
+++ b/crates/hir_def/src/lib.rs
@@ -76,7 +76,11 @@ use stdx::impl_from;
76#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 76#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
77pub struct ModuleId { 77pub struct ModuleId {
78 krate: CrateId, 78 krate: CrateId,
79 /// If this `ModuleId` was derived from a `DefMap` for a block expression, this stores the
80 /// `BlockId` of that block expression. If `None`, this module is part of the crate-level
81 /// `DefMap` of `krate`.
79 block: Option<BlockId>, 82 block: Option<BlockId>,
83 /// The module's ID in its originating `DefMap`.
80 pub local_id: LocalModuleId, 84 pub local_id: LocalModuleId,
81} 85}
82 86
@@ -87,7 +91,7 @@ impl ModuleId {
87 db.block_def_map(block).unwrap_or_else(|| { 91 db.block_def_map(block).unwrap_or_else(|| {
88 // NOTE: This should be unreachable - all `ModuleId`s come from their `DefMap`s, 92 // NOTE: This should be unreachable - all `ModuleId`s come from their `DefMap`s,
89 // so the `DefMap` here must exist. 93 // so the `DefMap` here must exist.
90 panic!("no `block_def_map` for `ModuleId` {:?}", self); 94 unreachable!("no `block_def_map` for `ModuleId` {:?}", self);
91 }) 95 })
92 } 96 }
93 None => db.crate_def_map(self.krate), 97 None => db.crate_def_map(self.krate),
@@ -650,7 +654,7 @@ fn macro_call_as_call_id(
650) -> Result<Result<MacroCallId, ErrorEmitted>, UnresolvedMacro> { 654) -> Result<Result<MacroCallId, ErrorEmitted>, UnresolvedMacro> {
651 let def: MacroDefId = resolver(call.path.clone()).ok_or(UnresolvedMacro)?; 655 let def: MacroDefId = resolver(call.path.clone()).ok_or(UnresolvedMacro)?;
652 656
653 let res = if let MacroDefKind::BuiltInEager(_) = def.kind { 657 let res = if let MacroDefKind::BuiltInEager(..) = def.kind {
654 let macro_call = InFile::new(call.ast_id.file_id, call.ast_id.to_node(db.upcast())); 658 let macro_call = InFile::new(call.ast_id.file_id, call.ast_id.to_node(db.upcast()));
655 let hygiene = Hygiene::new(db.upcast(), call.ast_id.file_id); 659 let hygiene = Hygiene::new(db.upcast(), call.ast_id.file_id);
656 660
@@ -669,7 +673,7 @@ fn macro_call_as_call_id(
669 Ok(res) 673 Ok(res)
670} 674}
671 675
672fn item_attr_as_call_id( 676fn derive_macro_as_call_id(
673 item_attr: &AstIdWithPath<ast::Item>, 677 item_attr: &AstIdWithPath<ast::Item>,
674 db: &dyn db::DefDatabase, 678 db: &dyn db::DefDatabase,
675 krate: CrateId, 679 krate: CrateId,
@@ -681,7 +685,7 @@ fn item_attr_as_call_id(
681 .as_lazy_macro( 685 .as_lazy_macro(
682 db.upcast(), 686 db.upcast(),
683 krate, 687 krate,
684 MacroCallKind::Attr(item_attr.ast_id, last_segment.to_string()), 688 MacroCallKind::Derive(item_attr.ast_id, last_segment.to_string()),
685 ) 689 )
686 .into(); 690 .into();
687 Ok(res) 691 Ok(res)