Skip to content

Commit fcbaf58

Browse files
Document fields of ModuleId
1 parent 8687844 commit fcbaf58

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/hir_def/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ use stdx::impl_from;
7676
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7777
pub struct ModuleId {
7878
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`.
7982
block: Option<BlockId>,
83+
/// The module's ID in its originating `DefMap`.
8084
pub local_id: LocalModuleId,
8185
}
8286

@@ -87,7 +91,7 @@ impl ModuleId {
8791
db.block_def_map(block).unwrap_or_else(|| {
8892
// NOTE: This should be unreachable - all `ModuleId`s come from their `DefMap`s,
8993
// so the `DefMap` here must exist.
90-
panic!("no `block_def_map` for `ModuleId` {:?}", self);
94+
unreachable!("no `block_def_map` for `ModuleId` {:?}", self);
9195
})
9296
}
9397
None => db.crate_def_map(self.krate),

0 commit comments

Comments
 (0)