summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-04 16:16:50 -0500
committerGitHub <noreply@github.com>2016-11-04 16:16:50 -0500
commitf4989039ce6366c25cc1650a9801b99d7e7a26a4 (patch)
tree63fae2ae7f30fb4e1210191e38efc286236678b1
parent7f88e8eb54ad0790920cedf41cb5a3a71c75a0dd (diff)
parentd14b602c4ee12e7f6efbbaa825124b7b774ac890 (diff)
Auto merge of #210 - fitzgen:dangling-item-id-in-partial-specializations, r=emilio
Dangling item id in partial specializations See individual commit messages for details. r? @emilio
-rw-r--r--src/ir/context.rs8
-rw-r--r--src/ir/item.rs3
2 files changed, 9 insertions, 2 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index c5c321c4..fc06375c 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -505,9 +505,15 @@ impl<'ctx> BindgenContext<'ctx> {
found_invalid_template_ref = true;
}
if c.kind() == CXCursor_TypeRef {
+ // The `with_id` id will potentially end up unused if we give up
+ // on this type (for example, its a tricky partial template
+ // specialization), so if we pass `with_id` as the parent, 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`.
let new_ty = Item::from_ty_or_ref(c.cur_type(),
Some(c),
- Some(with_id),
+ Some(wrapping),
self);
args.push(new_ty);
}
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 6eff60c9..6d2d4b02 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -88,7 +88,8 @@ impl ItemId {
/// Allocate the next `ItemId`.
pub fn next() -> Self {
static NEXT_ITEM_ID: AtomicUsize = ATOMIC_USIZE_INIT;
- ItemId(NEXT_ITEM_ID.fetch_add(1, Ordering::Relaxed))
+ let next_id = NEXT_ITEM_ID.fetch_add(1, Ordering::Relaxed);
+ ItemId(next_id)
}
}