From 6dd9c2e97c6b56b8a2c456663ea85ff1c46b7462 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 26 Feb 2021 18:16:14 -0500 Subject: [PATCH] [bindings] Be explicit when calling trait methods in generated code For ChannelManager, at least, we have two separate functions called block_connected, one in the Listen trait, one in the struct, we need to be explicit with which one we're trying to call. --- c-bindings-gen/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index a40875d9..5b99cd68 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -835,10 +835,16 @@ fn writeln_impl(w: &mut W, i: &syn::ItemImpl, types: &mut Typ takes_self = true; } } + + let mut t_gen_args = String::new(); + for (idx, _) in $trait.generics.params.iter().enumerate() { + if idx != 0 { t_gen_args += ", " }; + t_gen_args += "_" + } if takes_self { - write!(w, "unsafe {{ &mut *(this_arg as *mut native{}) }}.{}(", ident, $m.sig.ident).unwrap(); + write!(w, ">::{}(unsafe {{ &mut *(this_arg as *mut native{}) }}, ", ident, $trait.ident, t_gen_args, $m.sig.ident, ident).unwrap(); } else { - write!(w, "{}::{}::{}(", types.orig_crate, resolved_path, $m.sig.ident).unwrap(); + write!(w, ">::{}(", ident, $trait.ident, t_gen_args, $m.sig.ident).unwrap(); } let mut real_type = "".to_string(); -- 2.30.2