summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-07-21 02:36:08 -0700
committerGitHub <noreply@github.com>2017-07-21 02:36:08 -0700
commitb51ddf36c187b9aff8e3c4af54d450bd989f598b (patch)
tree9860e0f0b2d6b47945973b4ffe6a1d5772680ed8 /src
parent680094a8697547c80cbe4b036bd9b77b039c116f (diff)
parent3dedc2c8c87a8ea61eeed54c19c105cd73bb5490 (diff)
Auto merge of #829 - servo:disambig, r=emilio
Use fully disambiguated name instead of a number for layout tests (fixes #394) These numbers cause tons of churn in the diffs for checked in bindings. r? @fitzgen
Diffstat (limited to 'src')
-rw-r--r--src/codegen/mod.rs2
-rw-r--r--src/ir/item.rs27
2 files changed, 28 insertions, 1 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index c5c8ebee..0076f1df 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -772,7 +772,7 @@ impl CodeGenerator for TemplateInstantiation {
let size = layout.size;
let align = layout.align;
- let name = item.canonical_name(ctx);
+ let name = item.full_disambiguated_name(ctx);
let mut fn_name = format!("__bindgen_test_layout_{}_instantiation", name);
let times_seen = result.overload_number(&fn_name);
if times_seen > 0 {
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 2754c838..7f3afefb 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -661,6 +661,33 @@ impl Item {
}
}
+ /// Create a fully disambiguated name for an item, including template
+ /// parameters if it is a type
+ pub fn full_disambiguated_name(&self, ctx: &BindgenContext) -> String {
+ let mut s = String::new();
+ let level = 0;
+ self.push_disambiguated_name(ctx, &mut s, level);
+ s
+ }
+
+ /// Helper function for full_disambiguated_name
+ fn push_disambiguated_name(&self, ctx: &BindgenContext, to: &mut String, level: u8) {
+ to.push_str(&self.canonical_name(ctx));
+ if let ItemKind::Type(ref ty) = *self.kind() {
+ if let TypeKind::TemplateInstantiation(ref inst) = *ty.kind() {
+ to.push_str(&format!("_open{}_", level));
+ for arg in inst.template_arguments() {
+ arg.into_resolver()
+ .through_type_refs()
+ .resolve(ctx)
+ .push_disambiguated_name(ctx, to, level + 1);
+ to.push_str("_");
+ }
+ to.push_str(&format!("close{}", level));
+ }
+ }
+ }
+
/// Get this function item's name, or `None` if this item is not a function.
fn func_name(&self) -> Option<&str> {
match *self.kind() {