From: Matt Corallo Date: Fri, 26 Feb 2021 23:16:14 +0000 (-0500) Subject: [bindings] Be explicit when calling trait methods in generated code X-Git-Tag: v0.0.13~17^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6dd9c2e97c6b56b8a2c456663ea85ff1c46b7462;p=rust-lightning [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. --- diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index a40875d95..5b99cd681 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();