From 9e7c25670d70934a62f711c71e651854321c0d7b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 30 Apr 2021 23:40:51 +0000 Subject: [PATCH] Drop stale () -> u8 mapping (now) used in Rust-only code --- c-bindings-gen/src/blocks.rs | 8 ++------ c-bindings-gen/src/main.rs | 2 +- c-bindings-gen/src/types.rs | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/c-bindings-gen/src/blocks.rs b/c-bindings-gen/src/blocks.rs index 8817272..82b10ad 100644 --- a/c-bindings-gen/src/blocks.rs +++ b/c-bindings-gen/src/blocks.rs @@ -137,12 +137,8 @@ pub fn write_result_block(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> 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> 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(); diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 1f17fef..7f5a3ed 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -974,7 +974,7 @@ fn writeln_impl(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"]) { diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index 1b38108..5767866 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1742,7 +1742,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { } fn write_to_c_conversion_inline_prefix_inner(&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 { -- 2.30.2