From fcbaf585cbac8e94dd6e6f9bfe9cca455e90fb3b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 19 Mar 2021 00:06:35 +0100 Subject: Document fields of `ModuleId` --- crates/hir_def/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 21add086d..50e730444 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs @@ -76,7 +76,11 @@ use stdx::impl_from; #[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, + /// The module's ID in its originating `DefMap`. pub local_id: LocalModuleId, } @@ -87,7 +91,7 @@ impl ModuleId { 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), -- cgit v1.2.3