Document fields of ModuleId

This commit is contained in:
Jonas Schievink 2021-03-19 00:06:35 +01:00
parent 86878443b1
commit fcbaf585cb

View File

@ -76,7 +76,11 @@ macro_rules! eprintln {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ModuleId {
krate: CrateId,
/// If this `ModuleId` was derived from a `DefMap` for a block expression, this stores the
/// `BlockId` of that block expression. If `None`, this module is part of the crate-level
/// `DefMap` of `krate`.
block: Option<BlockId>,
/// The module's ID in its originating `DefMap`.
pub local_id: LocalModuleId,
}
@ -87,7 +91,7 @@ pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> {
db.block_def_map(block).unwrap_or_else(|| {
// NOTE: This should be unreachable - all `ModuleId`s come from their `DefMap`s,
// so the `DefMap` here must exist.
panic!("no `block_def_map` for `ModuleId` {:?}", self);
unreachable!("no `block_def_map` for `ModuleId` {:?}", self);
})
}
None => db.crate_def_map(self.krate),