Skip to content

Commit 6bbabff

Browse files
committed
Add more logging for item insertion and asserts
This adds `debug!` logging for all paths that insert items into `BindgenContext::items`, and adds some `debug_assert!`s against dangling `ItemId`s.
1 parent e20f4c9 commit 6bbabff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ir/context.rs

+4
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ impl<'ctx> BindgenContext<'ctx> {
415415
// If at some point we care about the memory here, probably a map TypeKind
416416
// -> builtin type ItemId would be the best to improve that.
417417
fn add_builtin_item(&mut self, item: Item) {
418+
debug!("add_builtin_item: item = {:?}", item);
418419
debug_assert!(item.kind().is_type());
419420
let id = item.id();
420421
let old_item = self.items.insert(id, item);
@@ -573,6 +574,8 @@ impl<'ctx> BindgenContext<'ctx> {
573574
};
574575

575576
// Bypass all the validations in add_item explicitly.
577+
debug!("build_template_wrapper: inserting item: {:?}", item);
578+
debug_assert!(with_id == item.id());
576579
self.items.insert(with_id, item);
577580
with_id
578581
}
@@ -990,6 +993,7 @@ impl<'ctx, 'gen> Iterator for WhitelistedItemsIter<'ctx, 'gen>
990993
};
991994

992995
debug_assert!(self.seen.contains(&id));
996+
debug_assert!(self.ctx.items.contains_key(&id));
993997

994998
let mut sub_types = ItemSet::new();
995999
id.collect_types(self.ctx, &mut sub_types, &());

0 commit comments

Comments
 (0)