[bindings] Be explicit when calling trait methods in generated code
authorMatt Corallo <git@bluematt.me>
Fri, 26 Feb 2021 23:16:14 +0000 (18:16 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 1 Mar 2021 00:44:45 +0000 (19:44 -0500)
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

index a40875d95cf83209bb7ec2008b76c9b54012f853..5b99cd681819df8ad6643272224cc97d57e8bc17 100644 (file)
@@ -835,10 +835,16 @@ fn writeln_impl<W: std::io::Write>(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, "<native{} as {}TraitImport<{}>>::{}(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, "<native{} as {}TraitImport<{}>>::{}(", ident, $trait.ident, t_gen_args, $m.sig.ident).unwrap();
                                                                }
 
                                                                let mut real_type = "".to_string();