From 8c4482592c31d3d50f82cee0058b51ac90c31de3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 2 Dec 2016 14:57:56 -0800 Subject: Assert that we do not infinitely loop in ir::Item::name_target This re-uses the infrastructure used when asserting that `ItemAncestorsIter` does not infinitely loop in `ir::Item::name_target`. --- libbindgen/src/ir/item.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libbindgen/src') diff --git a/libbindgen/src/ir/item.rs b/libbindgen/src/ir/item.rs index f4272e2d..74c65083 100644 --- a/libbindgen/src/ir/item.rs +++ b/libbindgen/src/ir/item.rs @@ -588,8 +588,13 @@ impl Item { ctx: &BindgenContext, for_name_checking: bool) -> ItemId { + let mut targets_seen = AncestorsSeen::new(); let mut item = self; + loop { + debug_assert!(!targets_seen.contains(&item.id())); + targets_seen.insert(item.id()); + match *item.kind() { ItemKind::Type(ref ty) => { match *ty.kind() { -- cgit v1.2.3