Skip to content

Commit bed241e

Browse files
committed
Take out template arguments and make unique names
1 parent 515ef38 commit bed241e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

libbindgen/src/codegen/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,25 @@ impl CodeGenerator for CompInfo {
655655
// also don't output template specializations, neither total or partial.
656656
//
657657
// TODO: Generate layout tests for template specializations, yay!
658+
659+
// TODO (imp): I will keep it like that right now and move it to function later
658660
if self.has_non_type_template_params() ||
659661
self.is_template_specialization() {
660662
let layout = item.kind().expect_type().layout(ctx);
661663
let canonical_name = item.canonical_name(ctx);
662664

663665
if let Some(layout) = layout {
664-
let fn_name = format!("bindgen_test_layout_template_{}", canonical_name);
666+
667+
let mut types = String::new();
668+
669+
for arg in self.template_args() {
670+
if let Some(name) = ctx.resolve_type(*arg).name() {
671+
// hope this isn't bad
672+
types.push_str(format!("{}_", name).as_str());
673+
}
674+
}
675+
676+
let fn_name = format!("bindgen_test_layout_template_{}_{}", canonical_name, types);
665677
let fn_name = ctx.rust_ident_raw(&fn_name);
666678
let ident = item.to_rust_ty(ctx);
667679
let prefix = ctx.trait_prefix();

0 commit comments

Comments
 (0)