]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Drop stale () -> u8 mapping (now) used in Rust-only code
authorMatt Corallo <git@bluematt.me>
Fri, 30 Apr 2021 23:40:51 +0000 (23:40 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 30 Apr 2021 23:40:51 +0000 (23:40 +0000)
c-bindings-gen/src/blocks.rs
c-bindings-gen/src/main.rs
c-bindings-gen/src/types.rs

index 88172722efbda088aef61443fba43e2af6515e07..82b10ad831bd4ca2ef21ec3c1d9804d5dbe6e26c 100644 (file)
@@ -137,12 +137,8 @@ pub fn write_result_block<W: std::io::Write>(w: &mut W, mangled_container: &str,
        writeln!(w, "\t}}").unwrap();
        writeln!(w, "}}").unwrap();
 
-       // TODO: Templates should use () now that they can, too
-       let templ_ok_type = if ok_type != "()" { ok_type } else { "u8" };
-       let templ_err_type = if err_type != "()" { err_type } else { "u8" };
-
-       writeln!(w, "impl From<crate::c_types::CResultTempl<{}, {}>> for {} {{", templ_ok_type, templ_err_type, mangled_container).unwrap();
-       writeln!(w, "\tfn from(mut o: crate::c_types::CResultTempl<{}, {}>) -> Self {{", templ_ok_type, templ_err_type).unwrap();
+       writeln!(w, "impl From<crate::c_types::CResultTempl<{}, {}>> for {} {{", ok_type, err_type, mangled_container).unwrap();
+       writeln!(w, "\tfn from(mut o: crate::c_types::CResultTempl<{}, {}>) -> Self {{", ok_type, err_type).unwrap();
        writeln!(w, "\t\tlet contents = if o.result_ok {{").unwrap();
        if ok_type != "()" {
                writeln!(w, "\t\t\tlet result = unsafe {{ o.contents.result }};").unwrap();
index 1f17fef9ead0dba1887eedd2134d6e3ce37eaa00..7f5a3ed4b33c0fa66b213646f8c720189593f330 100644 (file)
@@ -974,7 +974,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                        write!(w, "{}r", if new_var { "local_" } else { "" }).unwrap();
                                                        types.write_to_c_conversion_inline_suffix(w, &*i.self_ty, Some(&gen_types), false);
                                                        writeln!(w, "\n\t\t\t)\n\t\t}},").unwrap();
-                                                       writeln!(w, "\t\tErr(e) => crate::c_types::CResultTempl::err(0u8),").unwrap();
+                                                       writeln!(w, "\t\tErr(e) => crate::c_types::CResultTempl::err(()),").unwrap();
                                                        writeln!(w, "\t}}.into()\n}}").unwrap();
                                                }
                                        } else if path_matches_nongeneric(&trait_path.1, &["Display"]) {
index 1b3810878e782e86c9fc43353e4fbda96ef9226b..57678669a19ef1b6197ccfaf0f996bee3cd5465b 100644 (file)
@@ -1742,7 +1742,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        }
 
        fn write_to_c_conversion_inline_prefix_inner<W: std::io::Write>(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, ptr_for_ref: bool, from_ptr: bool) {
-               self.write_conversion_inline_intern(w, t, generics, is_ref, false, ptr_for_ref, "0u8 /*", true, |_, _| "local_".to_owned(),
+               self.write_conversion_inline_intern(w, t, generics, is_ref, false, ptr_for_ref, "() /*", true, |_, _| "local_".to_owned(),
                                |a, b, c| self.to_c_conversion_inline_prefix_from_path(a, b, c),
                                |w, decl_type, decl_path, is_ref, _is_mut| {
                                        match decl_type {