Skip to content

Commit 80185c9

Browse files
committed
ir: Document a bit better the local_id thing.
1 parent 1bdfc9e commit 80185c9

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
@@ -90,11 +90,16 @@ impl ItemCanonicalPath for ItemId {
9090
pub struct Item {
9191
/// This item's id.
9292
id: ItemId,
93+
9394
/// The item's local id, unique only amongst its siblings. Only used for
9495
/// anonymous items.
9596
///
9697
/// Lazily initialized in local_id().
98+
///
99+
/// Note that only structs, unions, and enums get a local type id. In any
100+
/// case this is an implementation detail.
97101
local_id: Cell<Option<usize>>,
102+
98103
/// The next local id to use for a child..
99104
next_child_local_id: Cell<usize>,
100105

@@ -519,6 +524,10 @@ impl Item {
519524
_ => {}
520525
}
521526
}
527+
528+
// Note that this `id_` prefix prevents (really unlikely) collisions
529+
// between the global id and the local id of an item with the same
530+
// parent.
522531
format!("id_{}", self.id().0)
523532
}
524533

0 commit comments

Comments
 (0)