summaryrefslogtreecommitdiff
path: root/src/ir/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/context.rs')
-rw-r--r--src/ir/context.rs24
1 files changed, 14 insertions, 10 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.