mirror of
git://git.proxmox.com/git/perlmod.git
synced 2025-01-19 18:03:36 +03:00
clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
f8b49fc1be
commit
76f6a079eb
@ -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...
|
||||
|
@ -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
|
||||
|
@ -9,7 +9,7 @@ mod export {
|
||||
|
||||
#[export]
|
||||
pub fn to_string(tristate: Option<bool>) -> String {
|
||||
format!("{:?}", tristate)
|
||||
format!("{tristate:?}")
|
||||
}
|
||||
|
||||
#[export]
|
||||
|
@ -40,19 +40,19 @@ mod export {
|
||||
|
||||
#[export]
|
||||
fn test(t: Option<String>) -> 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<String, Error> {
|
||||
println!("got {:?}", value);
|
||||
println!("got {value:?}");
|
||||
Ok(value.0)
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ mod export {
|
||||
|
||||
#[export]
|
||||
fn test_trailing_optional(first: u32, second: Option<u32>) {
|
||||
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(())
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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, "]")?;
|
||||
|
@ -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())) }
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ impl ScalarRef {
|
||||
|
||||
let bytes: [u8; mem::size_of::<usize>()] = 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:
|
||||
|
@ -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:?})",
|
||||
)));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user