Enable X-lang LTO for Windows x86-64 builds (or any extra build)
[ldk-c-bindings] / c-bindings-gen / src / types.rs
index 0c4c1d88694e3c5637cd60efb108ef9806894b1c..47ff515ffa85651ec424fc95fe3aa477aa3e55ad 100644 (file)
@@ -223,6 +223,15 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                                        if let Some(path) = types.maybe_resolve_path(&trait_bound.path, None) {
                                                                if types.skip_path(&path) { continue; }
                                                                if path == "Sized" { continue; }
+                                                               if path == "core::fmt::Debug" {
+                                                                       // #[derive(Debug)] will add Debug bounds on each genericin the
+                                                                       // auto-generated impl. In cases where the existing generic
+                                                                       // bound already requires Debug this is redundant and should be
+                                                                       // ignored (which we do here). However, in cases where this is
+                                                                       // not redundant, this may cause spurious Debug impls which may
+                                                                       // fail to compile.
+                                                                       continue;
+                                                               }
                                                                if non_lifetimes_processed { return false; }
                                                                non_lifetimes_processed = true;
                                                                if path != "std::ops::Deref" && path != "core::ops::Deref" &&
@@ -1028,6 +1037,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // Note that no !is_ref types can map to an array because Rust and C's call semantics
                        // for arrays are different (https://github.com/eqrion/cbindgen/issues/528)
 
+                       "[u8; 33]" if !is_ref => Some("crate::c_types::ThirtyThreeBytes"),
                        "[u8; 32]" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
                        "[u8; 20]" if !is_ref => Some("crate::c_types::TwentyBytes"),
                        "[u8; 16]" if !is_ref => Some("crate::c_types::SixteenBytes"),
@@ -1136,6 +1146,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "Option" if is_ref => Some("&local_"),
                        "Option" => Some("local_"),
 
+                       "[u8; 33]" if !is_ref => Some(""),
                        "[u8; 32]" if is_ref => Some("unsafe { &*"),
                        "[u8; 32]" if !is_ref => Some(""),
                        "[u8; 20]" if !is_ref => Some(""),
@@ -1250,6 +1261,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "Option" => Some(""),
                        "Result" if !is_ref => Some(""),
 
+                       "[u8; 33]" if !is_ref => Some(".data"),
                        "[u8; 32]" if is_ref => Some("}"),
                        "[u8; 32]" if !is_ref => Some(".data"),
                        "[u8; 20]" if !is_ref => Some(".data"),
@@ -1364,6 +1376,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "Vec" if !is_ref => Some("local_"),
                        "Option" => Some("local_"),
 
+                       "[u8; 33]" if is_ref => Some(""),
                        "[u8; 32]" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
                        "[u8; 32]" if is_ref => Some(""),
                        "[u8; 20]" if !is_ref => Some("crate::c_types::TwentyBytes { data: "),
@@ -1468,6 +1481,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "Vec" if !is_ref => Some(".into()"),
                        "Option" => Some(""),
 
+                       "[u8; 33]" if is_ref => Some(""),
                        "[u8; 32]" if !is_ref => Some(" }"),
                        "[u8; 32]" if is_ref => Some(""),
                        "[u8; 20]" if !is_ref => Some(" }"),