From 12e10bf5b2638d88b2e8d2b3b88672cb0fb8c88a Mon Sep 17 00:00:00 2001 From: Thibaut Lorrain Date: Fri, 21 Jul 2023 17:57:49 +0200 Subject: [PATCH] keep compat with rust 1.57.0 --- src/bindgen/ir/cfg.rs | 4 +-- src/bindgen/language_backend/java_jna.rs | 44 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/bindgen/ir/cfg.rs b/src/bindgen/ir/cfg.rs index 43d1e2b01..d50dd6b5f 100644 --- a/src/bindgen/ir/cfg.rs +++ b/src/bindgen/ir/cfg.rs @@ -350,7 +350,7 @@ impl ConditionWrite for Option { out.new_line(); } Language::JavaJna => { - write!(out, "/* begin condition not supported {self:?} */"); + write!(out, "/* begin condition not supported {:?} */", self); out.new_line(); } } @@ -371,7 +371,7 @@ impl ConditionWrite for Option { } Language::JavaJna => { out.new_line(); - write!(out, "/* end condition not supported {self:?} */"); + write!(out, "/* end condition not supported {:?} */", &self); } } } diff --git a/src/bindgen/language_backend/java_jna.rs b/src/bindgen/language_backend/java_jna.rs index 61c6de65c..c83f46131 100644 --- a/src/bindgen/language_backend/java_jna.rs +++ b/src/bindgen/language_backend/java_jna.rs @@ -27,7 +27,7 @@ impl LanguageBackend for JavaJnaLanguageBackend { fn write_headers(&self, out: &mut SourceWriter) { if let Some(ref header) = self.config.header { out.new_line_if_not_start(); - write!(out, "{header}"); + write!(out, "{}", header); out.new_line(); } @@ -42,13 +42,13 @@ impl LanguageBackend for JavaJnaLanguageBackend { } if let Some(ref autogen_warning) = self.config.autogen_warning { out.new_line_if_not_start(); - write!(out, "{autogen_warning}"); + write!(out, "{}", autogen_warning); out.new_line(); } if let Some(ref package) = self.config.java_jna.package { out.new_line_if_not_start(); - write!(out, "package {package};"); + write!(out, "package {};", package); out.new_line(); out.new_line(); } @@ -67,7 +67,7 @@ impl LanguageBackend for JavaJnaLanguageBackend { .java_jna .interface_name .clone() - .unwrap_or("Bindings".to_string()); + .unwrap_or_else(|| "Bindings".to_string()); write!(out, "enum {}Singleton", name); out.open_brace(); @@ -90,7 +90,7 @@ impl LanguageBackend for JavaJnaLanguageBackend { out.new_line(); if let Some(extra) = &self.config.java_jna.extra_defs { - write!(out, "{extra}"); + write!(out, "{}", extra); out.new_line(); } } else { @@ -174,13 +174,13 @@ fn write_integer_type)>( out.open_brace(); write!(out, "public {}()", name); out.open_brace(); - write!(out, "super({size});"); + write!(out, "super({});", size); out.close_brace(false); out.new_line(); out.new_line(); write!(out, "public {}(long value)", name); out.open_brace(); - write!(out, "super({size}, value);"); + write!(out, "super({}, value);", size); out.close_brace(false); out.new_line(); out.new_line(); @@ -198,19 +198,19 @@ fn write_integer_type)>( out.open_brace(); write!(out, "public {}ByReference()", name); out.open_brace(); - write!(out, "super({size});"); + write!(out, "super({});", size); out.close_brace(false); out.new_line(); out.new_line(); write!(out, "public {}ByReference(Pointer p)", name); out.open_brace(); - write!(out, "super({size});"); + write!(out, "super({});", size); out.new_line(); out.write("setPointer(p);"); out.close_brace(false); out.new_line(); out.new_line(); - write!(out, "{name} getValue()"); + write!(out, "{} getValue()", name); out.open_brace(); write!( out, @@ -221,7 +221,7 @@ fn write_integer_type)>( out.close_brace(false); out.new_line(); out.new_line(); - write!(out, "void setValue({name} value)"); + write!(out, "void setValue({} value)", name); out.open_brace(); write!(out, "getPointer().{};", jna_underlying_type.set_method()); out.close_brace(false); @@ -730,7 +730,7 @@ impl Source for Type { } } }; - write!(out, "{typ}") + write!(out, "{}", typ) } Type::Array(_, _) => out.write("Pointer"), Type::FuncPtr { .. } => out.write("CallbackReference"), @@ -767,7 +767,7 @@ impl Source for Type { } } }; - write!(out, "{typ}") + write!(out, "{}", typ) } Type::Array(ty, _len) => { ty.write(language_backend, out); @@ -789,7 +789,7 @@ impl Source for Documentation { out.write("/**"); for line in &self.doc_comment { out.new_line(); - write!(out, " *{line}") + write!(out, " *{}", line) } out.new_line(); out.write(" */"); @@ -802,20 +802,20 @@ pub(crate) fn wrap_java_value(literal: &Literal, ty: &Type) -> Literal { match literal { Literal::Expr(expr) => match ty { Type::Primitive(primitive) => match primitive { - PrimitiveType::Double => Literal::Expr(format!("{expr}d")), - PrimitiveType::Float => Literal::Expr(format!("{expr}f")), + PrimitiveType::Double => Literal::Expr(format!("{}d", expr)), + PrimitiveType::Float => Literal::Expr(format!("{}f", expr)), PrimitiveType::Integer { kind: IntKind::LongLong | IntKind::B64, .. - } => Literal::Expr(format!("{expr}L")), + } => Literal::Expr(format!("{}L", expr)), PrimitiveType::Integer { kind: IntKind::Long | IntKind::Size | IntKind::SizeT, .. - } => Literal::Expr(format!("new NativeLong({expr})")), + } => Literal::Expr(format!("new NativeLong({})", expr)), _ => literal.clone(), }, - Type::Path(path) => Literal::Expr(format!("new {}({expr})", path.export_name())), + Type::Path(path) => Literal::Expr(format!("new {}({})", path.export_name(), expr)), _ => literal.clone(), }, _ => literal.clone(), @@ -842,11 +842,11 @@ impl Source for Literal { ) { match &self { Literal::Expr(expr) => { - write!(out, "{expr}") + write!(out, "{}", expr) } Literal::Struct { export_name, .. } => { // There is an hashmap in there that doesn't have stable debug output - not_implemented(&format!("Struct Literal {export_name}"), out) + not_implemented(&format!("Struct Literal {}", export_name), out) } _ => not_implemented(self, out), } @@ -854,5 +854,5 @@ impl Source for Literal { } fn not_implemented(value: &T, out: &mut SourceWriter) { - write!(out, "/* Not implemented yet : {value:?} */") + write!(out, "/* Not implemented yet : {:?} */", value) }