Skip to content

Commit d14b602

Browse files
committed
Use a known-resolved ItemId as a parent in partial specialization children
The `with_id` id will potentially end up unused if we find we already have an item (with its own distinct `ItemId`) for the type, so if we pass `with_id` as the parent id when parsing children it is potentially a dangling reference. Instead, use the canonical template declaration as the parent. It is already parsed and has a known-resolvable `ItemId`.
1 parent 0afbe48 commit d14b602

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ir/context.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,15 @@ impl<'ctx> BindgenContext<'ctx> {
505505
found_invalid_template_ref = true;
506506
}
507507
if c.kind() == CXCursor_TypeRef {
508+
// The `with_id` id will potentially end up unused if we give up
509+
// on this type (for example, its a tricky partial template
510+
// specialization), so if we pass `with_id` as the parent, it is
511+
// potentially a dangling reference. Instead, use the canonical
512+
// template declaration as the parent. It is already parsed and
513+
// has a known-resolvable `ItemId`.
508514
let new_ty = Item::from_ty_or_ref(c.cur_type(),
509515
Some(c),
510-
Some(with_id),
516+
Some(wrapping),
511517
self);
512518
args.push(new_ty);
513519
}

0 commit comments

Comments
 (0)