summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/context.rs24
-rw-r--r--src/ir/item.rs10
2 files changed, 19 insertions, 15 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index b51a2cb9..9ffb1b7a 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -320,23 +320,27 @@ impl<'ctx> BindgenContext<'ctx> {
let mut replacements = vec![];
for (id, item) in self.items.iter() {
+ // Calls to `canonical_name` are expensive, so eagerly filter out
+ // items that cannot be replaced.
let ty = match item.kind().as_type() {
Some(ty) => ty,
None => continue,
};
- // canonical_name calls are expensive.
- let ci = match ty.as_comp() {
- Some(ci) => ci,
- None => continue,
- };
-
- if ci.is_template_specialization() {
- continue;
+ match *ty.kind() {
+ TypeKind::Comp(ref ci) if !ci.is_template_specialization() => {}
+ TypeKind::TemplateAlias(_, _) |
+ TypeKind::Alias(_, _) => {}
+ _ => continue,
}
- if let Some(replacement) = self.replacements
- .get(&item.canonical_name(self)) {
+ let name = item.real_canonical_name(self,
+ self.options()
+ .enable_cxx_namespaces,
+ true);
+ let replacement = self.replacements.get(&name);
+
+ if let Some(replacement) = replacement {
if replacement != id {
// We set this just after parsing the annotation. It's
// very unlikely, but this can happen.
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 690f4222..d986bb32 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -539,11 +539,11 @@ impl Item {
///
/// This name should be derived from the immutable state contained in the
/// type and the parent chain, since it should be consistent.
- fn real_canonical_name(&self,
- ctx: &BindgenContext,
- count_namespaces: bool,
- for_name_checking: bool)
- -> String {
+ pub fn real_canonical_name(&self,
+ ctx: &BindgenContext,
+ count_namespaces: bool,
+ for_name_checking: bool)
+ -> String {
let base_name = match *self.kind() {
ItemKind::Type(ref ty) => {
match *ty.kind() {