summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-10-23 18:44:30 +0200
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-10-29 22:25:20 +0200
commit3802c99c85daad5e5e92255b0569611ad2c1d01c (patch)
treea9093d940171782414fe870d42114f0c8f6f1bb1
parent955e689a83f614f0549249f08f91e4602a033819 (diff)
ir: Document a bit better the local_id thing.
-rw-r--r--src/ir/item.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 85fc95a3..0d409f04 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -97,11 +97,16 @@ impl ItemCanonicalPath for ItemId {
pub struct Item {
/// This item's id.
id: ItemId,
+
/// The item's local id, unique only amongst its siblings. Only used for
/// anonymous items.
///
/// Lazily initialized in local_id().
+ ///
+ /// Note that only structs, unions, and enums get a local type id. In any
+ /// case this is an implementation detail.
local_id: Cell<Option<usize>>,
+
/// The next local id to use for a child..
next_child_local_id: Cell<usize>,
@@ -546,6 +551,10 @@ impl Item {
_ => {}
}
}
+
+ // Note that this `id_` prefix prevents (really unlikely) collisions
+ // between the global id and the local id of an item with the same
+ // parent.
format!("id_{}", self.id().0)
}