diff --git a/build.rs b/build.rs index fb06b28..461ac1f 100644 --- a/build.rs +++ b/build.rs @@ -31,7 +31,7 @@ pub trait PHPProvider<'a>: Sized { /// Writes the bindings to a file. fn write_bindings(&self, bindings: String, writer: &mut impl Write) -> Result<()> { for line in bindings.lines() { - writeln!(writer, "{}", line)?; + writeln!(writer, "{line}")?; } Ok(()) } @@ -126,7 +126,7 @@ impl PHPInfo { } fn get_key(&self, key: &str) -> Option<&str> { - let split = format!("{} => ", key); + let split = format!("{key} => "); for line in self.0.lines() { let components: Vec<_> = line.split(&split).collect(); if components.len() > 1 { @@ -160,11 +160,7 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result Result<()> { println!("cargo:rerun-if-changed={}", path.to_string_lossy()); } for env_var in ["PHP", "PHP_CONFIG", "PATH"] { - println!("cargo:rerun-if-env-changed={}", env_var); + println!("cargo:rerun-if-env-changed={env_var}"); } println!("cargo:rerun-if-changed=build.rs"); diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index c145bbd..496e5ce 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -10,7 +10,7 @@ use dialoguer::{Confirm, Select}; use std::{ fs::OpenOptions, - io::{BufRead, BufReader, Seek, SeekFrom, Write}, + io::{BufRead, BufReader, Seek, Write}, path::PathBuf, process::{Command, Stdio}, }; @@ -207,7 +207,7 @@ impl Install { .open(php_ini) .with_context(|| "Failed to open `php.ini`")?; - let mut ext_line = format!("extension={}", ext_name); + let mut ext_line = format!("extension={ext_name}"); let mut new_lines = vec![]; for line in BufReader::new(&file).lines() { @@ -225,7 +225,7 @@ impl Install { } new_lines.push(ext_line); - file.seek(SeekFrom::Start(0))?; + file.rewind()?; file.set_len(0)?; file.write(new_lines.join("\n").as_bytes()) .with_context(|| "Failed to update `php.ini`")?; @@ -255,9 +255,8 @@ fn get_ext_dir() -> AResult { ext_dir ); } else { - std::fs::create_dir(&ext_dir).with_context(|| { - format!("Failed to create extension directory at {:?}", ext_dir) - })?; + std::fs::create_dir(&ext_dir) + .with_context(|| format!("Failed to create extension directory at {ext_dir:?}"))?; } } Ok(ext_dir) @@ -341,7 +340,7 @@ impl Remove { } } - file.seek(SeekFrom::Start(0))?; + file.rewind()?; file.set_len(0)?; file.write(new_lines.join("\n").as_bytes()) .with_context(|| "Failed to update `php.ini`")?; @@ -389,7 +388,7 @@ impl Stubs { .with_context(|| "Failed to generate stubs.")?; if self.stdout { - print!("{}", stubs); + print!("{stubs}"); } else { let out_path = if let Some(out_path) = &self.out { Cow::Borrowed(out_path) diff --git a/crates/macros/src/function.rs b/crates/macros/src/function.rs index 9efa5b1..5e3def2 100644 --- a/crates/macros/src/function.rs +++ b/crates/macros/src/function.rs @@ -52,7 +52,7 @@ pub fn parser(args: AttributeArgs, input: ItemFn) -> Result<(TokenStream, Functi .. } = &sig; - let internal_ident = Ident::new(&format!("_internal_php_{}", ident), Span::call_site()); + let internal_ident = Ident::new(&format!("_internal_php_{ident}"), Span::call_site()); let args = build_args(inputs, &attr_args.defaults)?; let optional = find_optional_parameter(args.iter(), attr_args.optional); let arg_definitions = build_arg_definitions(&args); diff --git a/crates/macros/src/method.rs b/crates/macros/src/method.rs index 87e12c7..7eb8a34 100644 --- a/crates/macros/src/method.rs +++ b/crates/macros/src/method.rs @@ -136,7 +136,7 @@ pub fn parser( } else { quote! { return; } }; - let internal_ident = Ident::new(&format!("_internal_php_{}", ident), Span::call_site()); + let internal_ident = Ident::new(&format!("_internal_php_{ident}"), Span::call_site()); let args = build_args(struct_ty, &mut input.sig.inputs, &defaults)?; let optional = function::find_optional_parameter( args.iter().filter_map(|arg| match arg { diff --git a/crates/macros/src/startup_function.rs b/crates/macros/src/startup_function.rs index 294d7ad..695753d 100644 --- a/crates/macros/src/startup_function.rs +++ b/crates/macros/src/startup_function.rs @@ -68,7 +68,7 @@ fn build_classes(classes: &HashMap) -> Result> { .map(|(name, class)| { let Class { class_name, .. } = &class; let ident = Ident::new(name, Span::call_site()); - let meta = Ident::new(&format!("_{}_META", name), Span::call_site()); + let meta = Ident::new(&format!("_{name}_META"), Span::call_site()); let methods = class.methods.iter().map(|method| { let builder = method.get_builder(&ident); let flags = method.get_flags(); diff --git a/src/describe/stub.rs b/src/describe/stub.rs index 4c501f6..65c0e76 100644 --- a/src/describe/stub.rs +++ b/src/describe/stub.rs @@ -84,7 +84,7 @@ impl ToStub for Module { .map(|(ns, entries)| { let mut buf = String::new(); if let Some(ns) = ns { - writeln!(buf, "namespace {} {{", ns)?; + writeln!(buf, "namespace {ns} {{")?; } else { writeln!(buf, "namespace {{")?; } @@ -183,7 +183,7 @@ impl ToStub for DocBlock { if !self.0.is_empty() { writeln!(buf, "/**")?; for comment in self.0.iter() { - writeln!(buf, " *{}", comment)?; + writeln!(buf, " *{comment}")?; } writeln!(buf, " */")?; } @@ -196,10 +196,10 @@ impl ToStub for Class { self.docs.fmt_stub(buf)?; let (_, name) = split_namespace(self.name.as_ref()); - write!(buf, "class {} ", name)?; + write!(buf, "class {name} ")?; if let Option::Some(extends) = &self.extends { - write!(buf, "extends {} ", extends)?; + write!(buf, "extends {extends} ")?; } if !self.implements.is_empty() { @@ -249,7 +249,7 @@ impl ToStub for Property { } write!(buf, "${}", self.name)?; if let Option::Some(default) = &self.default { - write!(buf, " = {}", default)?; + write!(buf, " = {default}")?; } writeln!(buf, ";") } @@ -311,7 +311,7 @@ impl ToStub for Constant { write!(buf, "const {} = ", self.name)?; if let Option::Some(value) = &self.value { - write!(buf, "{}", value)?; + write!(buf, "{value}")?; } else { write!(buf, "null")?; } @@ -381,6 +381,7 @@ mod test { #[test] #[cfg(not(windows))] + #[allow(clippy::uninlined_format_args)] pub fn test_indent() { use super::indent; use crate::describe::stub::NEW_LINE_SEPARATOR; diff --git a/src/error.rs b/src/error.rs index eaa0773..841228e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -65,17 +65,15 @@ impl Display for Error { match self { Error::IncorrectArguments(n, expected) => write!( f, - "Expected at least {} arguments, got {} arguments.", - expected, n + "Expected at least {expected} arguments, got {n} arguments." ), Error::ZvalConversion(ty) => write!( f, - "Could not convert Zval from type {} into primitive type.", - ty + "Could not convert Zval from type {ty} into primitive type." ), - Error::UnknownDatatype(dt) => write!(f, "Unknown datatype {}.", dt), + Error::UnknownDatatype(dt) => write!(f, "Unknown datatype {dt}."), Error::InvalidTypeToDatatype(dt) => { - write!(f, "Type flags did not contain a datatype: {:?}", dt) + write!(f, "Type flags did not contain a datatype: {dt:?}") } Error::InvalidScope => write!(f, "Invalid scope."), Error::InvalidPointer => write!(f, "Invalid pointer."), @@ -87,12 +85,12 @@ impl Display for Error { Error::InvalidUtf8 => write!(f, "Invalid Utf8 byte sequence."), Error::Callable => write!(f, "Could not call given function."), Error::InvalidException(flags) => { - write!(f, "Invalid exception type was thrown: {:?}", flags) + write!(f, "Invalid exception type was thrown: {flags:?}") } Error::IntegerOverflow => { write!(f, "Converting integer arguments resulted in an overflow.") } - Error::Exception(e) => write!(f, "Exception was thrown: {:?}", e), + Error::Exception(e) => write!(f, "Exception was thrown: {e:?}"), } } } diff --git a/src/props.rs b/src/props.rs index 6865b00..e82bcb2 100644 --- a/src/props.rs +++ b/src/props.rs @@ -140,7 +140,7 @@ impl<'a, T: 'a> Property<'a, T> { let value = get(self_); value .set_zval(retval, false) - .map_err(|e| format!("Failed to return property value to PHP: {:?}", e))?; + .map_err(|e| format!("Failed to return property value to PHP: {e:?}"))?; Ok(()) }) as Box PhpResult + Send + Sync + 'a> }); @@ -196,7 +196,7 @@ impl<'a, T: 'a> Property<'a, T> { match self { Property::Field(field) => field(self_) .get(retval) - .map_err(|e| format!("Failed to get property value: {:?}", e).into()), + .map_err(|e| format!("Failed to get property value: {e:?}").into()), Property::Method { get, set: _ } => match get { Some(get) => get(self_, retval), None => Err("No getter available for this property.".into()), @@ -244,7 +244,7 @@ impl<'a, T: 'a> Property<'a, T> { match self { Property::Field(field) => field(self_) .set(value) - .map_err(|e| format!("Failed to set property value: {:?}", e).into()), + .map_err(|e| format!("Failed to set property value: {e:?}").into()), Property::Method { get: _, set } => match set { Some(set) => set(self_, value), None => Err("No setter available for this property.".into()), diff --git a/src/zend/handlers.rs b/src/zend/handlers.rs index 4ec4ef9..11d220b 100644 --- a/src/zend/handlers.rs +++ b/src/zend/handlers.rs @@ -176,7 +176,7 @@ impl ZendObjectHandlers { continue; } props.insert(name, zv).map_err(|e| { - format!("Failed to insert value into properties hashtable: {:?}", e) + format!("Failed to insert value into properties hashtable: {e:?}") })?; }