Skip to content

Commit 3802c99

Browse files
committed
ir: Document a bit better the local_id thing.
1 parent 955e689 commit 3802c99

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ir/item.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ impl ItemCanonicalPath for ItemId {
9797
pub struct Item {
9898
/// This item's id.
9999
id: ItemId,
100+
100101
/// The item's local id, unique only amongst its siblings. Only used for
101102
/// anonymous items.
102103
///
103104
/// Lazily initialized in local_id().
105+
///
106+
/// Note that only structs, unions, and enums get a local type id. In any
107+
/// case this is an implementation detail.
104108
local_id: Cell<Option<usize>>,
109+
105110
/// The next local id to use for a child..
106111
next_child_local_id: Cell<usize>,
107112

@@ -546,6 +551,10 @@ impl Item {
546551
_ => {}
547552
}
548553
}
554+
555+
// Note that this `id_` prefix prevents (really unlikely) collisions
556+
// between the global id and the local id of an item with the same
557+
// parent.
549558
format!("id_{}", self.id().0)
550559
}
551560

0 commit comments

Comments
 (0)