diff --git a/perlmod-macro/src/function.rs b/perlmod-macro/src/function.rs index 9e982c2..5260878 100644 --- a/perlmod-macro/src/function.rs +++ b/perlmod-macro/src/function.rs @@ -83,10 +83,10 @@ pub fn handle_function( .xs_name .clone() .unwrap_or_else(|| match mangled_package_name { - None => Ident::new(&format!("xs_{}", name), name.span()), - Some(prefix) => Ident::new(&format!("xs_{}_{}", prefix, name), name.span()), + None => Ident::new(&format!("xs_{name}"), name.span()), + Some(prefix) => Ident::new(&format!("xs_{prefix}_{name}"), name.span()), }); - let impl_xs_name = Ident::new(&format!("impl_xs_{}", name), name.span()); + let impl_xs_name = Ident::new(&format!("impl_xs_{name}"), name.span()); let mut trailing_options = 0; let mut extract_arguments = TokenStream::new(); @@ -134,12 +134,12 @@ pub fn handle_function( continue; } - let extracted_name = Ident::new(&format!("extracted_arg_{}", arg_name), arg_name.span()); + let extracted_name = Ident::new(&format!("extracted_arg_{arg_name}"), arg_name.span()); let deserialized_name = - Ident::new(&format!("deserialized_arg_{}", arg_name), arg_name.span()); + Ident::new(&format!("deserialized_arg_{arg_name}"), arg_name.span()); let missing_message = syn::LitStr::new( - &format!("missing required parameter: '{}'\n", arg_name), + &format!("missing required parameter: '{arg_name}'\n"), arg_name.span(), ); @@ -553,7 +553,7 @@ pub fn get_result_type(ty: &syn::Type) -> (&syn::Type, bool) { /// Get a non-suffixed integer from an usize. fn simple_usize(i: usize, span: Span) -> syn::LitInt { - syn::LitInt::new(&format!("{}", i), span) + syn::LitInt::new(&format!("{i}"), span) } /// Note that we cannot handle renamed imports at all here... diff --git a/perlmod-macro/src/package.rs b/perlmod-macro/src/package.rs index 75b4528..313f6a4 100644 --- a/perlmod-macro/src/package.rs +++ b/perlmod-macro/src/package.rs @@ -132,10 +132,10 @@ impl Package { ); if let Some(lib) = &self.attrs.lib_name { - source = source.replace("{{LIB_NAME}}", &format!("('{}')", lib)); + source = source.replace("{{LIB_NAME}}", &format!("('{lib}')")); } else { let lib_name = get_default_lib_name(Span::call_site())?; - source = source.replace("{{LIB_NAME}}", &format!("('{}')", lib_name)); + source = source.replace("{{LIB_NAME}}", &format!("('{lib_name}')")); } let file_name = self diff --git a/perlmod-test/src/option.rs b/perlmod-test/src/option.rs index 257ba5a..f71540e 100644 --- a/perlmod-test/src/option.rs +++ b/perlmod-test/src/option.rs @@ -9,7 +9,7 @@ mod export { #[export] pub fn to_string(tristate: Option) -> String { - format!("{:?}", tristate) + format!("{tristate:?}") } #[export] diff --git a/perlmod-test/src/pkg142.rs b/perlmod-test/src/pkg142.rs index 5ae25c8..11d528b 100644 --- a/perlmod-test/src/pkg142.rs +++ b/perlmod-test/src/pkg142.rs @@ -40,19 +40,19 @@ mod export { #[export] fn test(t: Option) -> Result<(), Error> { - println!("test called with {:?}", t); + println!("test called with {t:?}"); Ok(()) } #[export] fn teststr(t: Option<&str>) -> Result<(), Error> { - println!("teststr called with {:?}", t); + println!("teststr called with {t:?}"); Ok(()) } #[export] fn test_serde(value: super::Blubber) -> Result { - println!("got {:?}", value); + println!("got {value:?}"); Ok(value.0) } @@ -73,7 +73,7 @@ mod export { #[export] fn test_trailing_optional(first: u32, second: Option) { - println!("{:?}, {:?}", first, second); + println!("{first:?}, {second:?}"); } #[export(xs_name = "testit_xsub")] @@ -93,7 +93,7 @@ mod expanded_export { #[export] fn test_lib_env_vars(value: &str) -> Result<(), Error> { - println!("foo: {:?}", value); + println!("foo: {value:?}"); Ok(()) } } diff --git a/perlmod/build.rs b/perlmod/build.rs index 047005d..00c1064 100644 --- a/perlmod/build.rs +++ b/perlmod/build.rs @@ -7,8 +7,8 @@ use std::{env, fs, io}; fn main() { let out_dir = env::var("OUT_DIR").expect("expected OUT_DIR to be set by cargo"); - let include_dir = format!("{}/include", out_dir); - let ppport_h_file = format!("{}/ppport.h", include_dir); + let include_dir = format!("{out_dir}/include"); + let ppport_h_file = format!("{include_dir}/ppport.h"); // quoted, without exterial double qoutes let ppport_h_file_string_inner = ppport_h_file.replace('"', "\\\""); @@ -23,8 +23,7 @@ fn main() { .arg("-MDevel::PPPort") .arg("-e") .arg(&format!( - r#"Devel::PPPort::WriteFile("{}");"#, - ppport_h_file_string_inner + r#"Devel::PPPort::WriteFile("{ppport_h_file_string_inner}");"# )) .output() .expect("failed to create ppport.h file using perl's Devel::PPPort"); diff --git a/perlmod/src/array.rs b/perlmod/src/array.rs index 9c9aa08..d0e510f 100644 --- a/perlmod/src/array.rs +++ b/perlmod/src/array.rs @@ -161,10 +161,10 @@ impl std::fmt::Debug for Array { let mut comma = false; for i in self { if comma { - write!(f, ", {:?}", i)?; + write!(f, ", {i:?}")?; } else { comma = true; - write!(f, "{:?}", i)?; + write!(f, "{i:?}")?; } } write!(f, "]")?; diff --git a/perlmod/src/de.rs b/perlmod/src/de.rs index 6cfd786..99017f3 100644 --- a/perlmod/src/de.rs +++ b/perlmod/src/de.rs @@ -72,8 +72,7 @@ impl<'deserializer> Deserializer<'deserializer> { match value.ty() { Type::Scalar(_) => Ok(()), Type::Other(other) => Err(Error(format!( - "cannot deserialize weird magic perl values ({})", - other + "cannot deserialize weird magic perl values ({other})" ))), // These are impossible as they are all handled by different Value enum types: Type::Reference => Error::fail("Value::Scalar: containing a reference"), @@ -185,7 +184,7 @@ impl<'deserializer> Deserializer<'deserializer> { /// lifetime needs to only live as long as the serializer, and we feed our serializer with the data /// from a borrowed Value (keeping references to all the contained data within perl), which lives /// longer than the deserializer. -unsafe fn str_set_wrong_lifetime<'a, 'b>(s: &'a str) -> &'b str { +unsafe fn str_set_wrong_lifetime<'a>(s: &'_ str) -> &'a str { unsafe { std::str::from_utf8_unchecked(std::slice::from_raw_parts(s.as_ptr(), s.len())) } } diff --git a/perlmod/src/error.rs b/perlmod/src/error.rs index 75891c7..b47fe0a 100644 --- a/perlmod/src/error.rs +++ b/perlmod/src/error.rs @@ -70,15 +70,14 @@ impl fmt::Display for MagicError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { MagicError::NotAReference(class) => { - write!(f, "value blessed into {} was not a reference", class) + write!(f, "value blessed into {class} was not a reference") } MagicError::NotFound("") => { write!(f, "value did not contain the requested magic pointer") } MagicError::NotFound(class) => write!( f, - "value blessed into {} did not contain its declared magic pointer", - class + "value blessed into {class} did not contain its declared magic pointer" ), } } diff --git a/perlmod/src/scalar.rs b/perlmod/src/scalar.rs index 0a7ca00..9d53a85 100644 --- a/perlmod/src/scalar.rs +++ b/perlmod/src/scalar.rs @@ -368,7 +368,7 @@ impl ScalarRef { let bytes: [u8; mem::size_of::()] = bytes .try_into() - .map_err(|err| Error(format!("invalid value for pointer: {}", err)))?; + .map_err(|err| Error(format!("invalid value for pointer: {err}")))?; Ok(usize::from_ne_bytes(bytes) as *mut T) } @@ -539,9 +539,9 @@ impl ScalarRef { /// # Safety /// /// It is up to the user to ensure the correct types are used in the provided `MagicSpec`. - pub fn find_magic<'a, 's, 'm, T: Leakable>( - &'s self, - spec: &'m MagicSpec<'static, 'static, T>, + pub fn find_magic<'a, T: Leakable>( + &'_ self, + spec: &'_ MagicSpec<'static, 'static, T>, ) -> Option<&'a T::Pointee> { match self.find_raw_magic(spec.how, Some(spec.vtbl)) { None => None, @@ -666,8 +666,7 @@ impl serde::Serialize for Scalar { } } Type::Other(other) => Err(S::Error::custom(format!( - "cannot serialize weird magic perl values ({})", - other, + "cannot serialize weird magic perl values ({other})", ))), // These are impossible as they are all handled by different Value enum types: diff --git a/perlmod/src/value.rs b/perlmod/src/value.rs index b320b0c..d4e9176 100644 --- a/perlmod/src/value.rs +++ b/perlmod/src/value.rs @@ -322,8 +322,7 @@ impl Value { let reftype = ptr.reftype(true); if reftype != package { return Err(Error::new_owned(format!( - "value not blessed into {:?} (`ref` returned {:?})", - package, reftype, + "value not blessed into {package:?} (`ref` returned {reftype:?})", ))); }