diff --git a/perlmod-macro/src/function.rs b/perlmod-macro/src/function.rs index 4304546..e3672fe 100644 --- a/perlmod-macro/src/function.rs +++ b/perlmod-macro/src/function.rs @@ -116,7 +116,7 @@ pub fn handle_function( let pat_ty = match arg { syn::FnArg::Receiver(_) => bail!(arg => "cannot export self-taking methods as xsubs"), syn::FnArg::Typed(ref mut pt) => { - pt.attrs.retain(|attr| !argument_attrs.handle_attr(&attr)); + pt.attrs.retain(|attr| !argument_attrs.handle_attr(attr)); argument_attrs.validate(pt.span())?; &*pt } @@ -328,6 +328,7 @@ struct ReturnHandling { wrapper_func: TokenStream, } +#[allow(clippy::too_many_arguments)] fn handle_return_kind( attr: &FunctionAttrs, ret: Return, diff --git a/perlmod-macro/src/lib.rs b/perlmod-macro/src/lib.rs index 3fafb87..cd9661b 100644 --- a/perlmod-macro/src/lib.rs +++ b/perlmod-macro/src/lib.rs @@ -128,7 +128,9 @@ fn handle_error(result: Result) -> TokenStream { data } -thread_local!(static NON_FATAL_ERRORS: RefCell> = RefCell::new(None)); +thread_local! { + static NON_FATAL_ERRORS: RefCell> = const { RefCell::new(None) }; +} /// The local error TLS must be freed at the end of a macro as any leftover `TokenStream` (even an /// empty one) will just panic between different runs as the multiple source files are handled by diff --git a/perlmod-test/src/lib.rs b/perlmod-test/src/lib.rs index 54e7b5a..95a030d 100644 --- a/perlmod-test/src/lib.rs +++ b/perlmod-test/src/lib.rs @@ -2,10 +2,12 @@ /// been stabilized then. mod pkg142; +/* #[cfg(feature = "rustmuchlater")] /// The following is what we ideally want to reach with future rust versions. It is technically /// possible on nightly with #![feature(custom_inner_attributes)] mod pkginline; +*/ /// A test for blessed values. mod bless; diff --git a/perlmod/build.rs b/perlmod/build.rs index 00c1064..e2d88e9 100644 --- a/perlmod/build.rs +++ b/perlmod/build.rs @@ -22,7 +22,7 @@ fn main() { Command::new("perl") .arg("-MDevel::PPPort") .arg("-e") - .arg(&format!( + .arg(format!( r#"Devel::PPPort::WriteFile("{ppport_h_file_string_inner}");"# )) .output() diff --git a/perlmod/src/error.rs b/perlmod/src/error.rs index 0a942c3..369cebc 100644 --- a/perlmod/src/error.rs +++ b/perlmod/src/error.rs @@ -88,7 +88,7 @@ impl fmt::Display for MagicError { impl std::error::Error for MagicError {} thread_local! { - static ERRNO: Cell = Cell::new(0); + static ERRNO: Cell = const { Cell::new(0) }; } /// Set the perlmod-specific `errno` value. This is *not* libc's `errno`, but a separate storage @@ -108,6 +108,11 @@ pub fn get_errno() -> c_int { /// This is part of the proc-macro API and is of little use to users of this crate directly. /// When manually implementing "xsubs" this can be used before returning as a shortcut to copying /// the perlmod errno value to libc. +/// +/// # Safety +/// +/// This is generally safe, but care should be taken as this manipulates `errno` and any C call +/// might mess it up again. pub unsafe fn copy_errno_to_libc() { unsafe { libc::__errno_location().write(get_errno()); diff --git a/perlmod/src/hash.rs b/perlmod/src/hash.rs index 64b94c5..96a56d4 100644 --- a/perlmod/src/hash.rs +++ b/perlmod/src/hash.rs @@ -111,7 +111,7 @@ impl Hash { unsafe { ffi::RSPL_hv_store( self.hv(), - key.as_ptr() as *const u8 as *const libc::c_char, + key.as_ptr() as *const libc::c_char, key.len() as i32, value.into_raw(), ); diff --git a/perlmod/src/magic.rs b/perlmod/src/magic.rs index fc4dfeb..47f7691 100644 --- a/perlmod/src/magic.rs +++ b/perlmod/src/magic.rs @@ -144,6 +144,7 @@ unsafe impl Send for MagicTag {} impl MagicTag { /// Create a new tag. See [`MagicSpec`] for its usage. + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Self(ffi::MGVTBL::zero(), PhantomData) } diff --git a/perlmod/src/raw_value.rs b/perlmod/src/raw_value.rs index 81d6234..808b876 100644 --- a/perlmod/src/raw_value.rs +++ b/perlmod/src/raw_value.rs @@ -11,7 +11,7 @@ use crate::Value; pub(crate) const NAME: &str = "$__perlmod_private_RawValue"; pub(crate) const VALUE: &str = "$__perlmod_private_raw_value"; -thread_local!(static SERIALIZE_RAW: RefCell = RefCell::new(false)); +thread_local!(static SERIALIZE_RAW: RefCell = const { RefCell::new(false) }); pub(crate) struct RawGuard(bool); diff --git a/perlmod/src/value.rs b/perlmod/src/value.rs index d4e9176..5ac1095 100644 --- a/perlmod/src/value.rs +++ b/perlmod/src/value.rs @@ -225,7 +225,7 @@ impl Value { /// The caller must ensure that it is safe to decrease the reference count later on, or use /// `into_raw()` instead of letting the `Value` get dropped. pub unsafe fn from_raw_move(ptr: *mut SV) -> Self { - Self::from_scalar(unsafe { Scalar::from_raw_move(ptr as *mut SV) }) + Self::from_scalar(unsafe { Scalar::from_raw_move(ptr) }) } /// Create a new reference to an existing `SV` value. This will increase the value's reference @@ -235,7 +235,7 @@ impl Value { /// /// The caller may still need to decrease the reference count for the `ptr` source value. pub unsafe fn from_raw_ref(ptr: *mut SV) -> Self { - Self::from_scalar(unsafe { Scalar::from_raw_ref(ptr as *mut SV) }) + Self::from_scalar(unsafe { Scalar::from_raw_ref(ptr) }) } /// Convert a [`Scalar`] to a [`Value`].