]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Explicitly refer to `format!()` with an `alloc` prefix for no-std
authorMatt Corallo <git@bluematt.me>
Wed, 2 Mar 2022 05:33:31 +0000 (05:33 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 2 Mar 2022 05:37:05 +0000 (05:37 +0000)
c-bindings-gen/src/main.rs
c-bindings-gen/src/types.rs

index 97f44a4c4c458e22ce017c0b8c53d8524077cea2..647f344bcefa5dba7ed4df54926157f69ffc951e 100644 (file)
@@ -1248,7 +1248,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                let self_ty = &i.self_ty;
                                                let ref_type: syn::Type = syn::parse_quote!(&#self_ty);
                                                let new_var = types.write_from_c_conversion_new_var(w, &format_ident!("o"), &ref_type, Some(&gen_types));
-                                               write!(w, "\tformat!(\"{{}}\", ").unwrap();
+                                               write!(w, "\talloc::format!(\"{{}}\", ").unwrap();
                                                types.write_from_c_conversion_prefix(w, &ref_type, Some(&gen_types));
                                                write!(w, "{}o", if new_var { "local_" } else { "" }).unwrap();
                                                types.write_from_c_conversion_suffix(w, &ref_type, Some(&gen_types));
index 88d66403931c34b2792e932309e2dfa08f09b226..aebeb487ece66605a3770677b9d386041bc29a13 100644 (file)
@@ -1133,7 +1133,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "std::time::Duration"|"core::time::Duration" => Some(""),
                        "std::time::SystemTime" => Some(""),
                        "std::io::Error" if !is_ref => Some("crate::c_types::IOError::from_rust("),
-                       "core::fmt::Arguments" => Some("format!(\"{}\", "),
+                       "core::fmt::Arguments" => Some("alloc::format!(\"{}\", "),
 
                        "core::convert::Infallible" => Some("panic!(\"Cannot construct an Infallible: "),