mirror of
git://git.proxmox.com/git/perlmod.git
synced 2024-12-21 17:33:52 +03:00
clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
5e2a30e18c
commit
1adcd9727e
@ -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,
|
||||
|
@ -128,7 +128,9 @@ fn handle_error(result: Result<TokenStream, Error>) -> TokenStream {
|
||||
data
|
||||
}
|
||||
|
||||
thread_local!(static NON_FATAL_ERRORS: RefCell<Option<TokenStream>> = RefCell::new(None));
|
||||
thread_local! {
|
||||
static NON_FATAL_ERRORS: RefCell<Option<TokenStream>> = 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
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -88,7 +88,7 @@ impl fmt::Display for MagicError {
|
||||
impl std::error::Error for MagicError {}
|
||||
|
||||
thread_local! {
|
||||
static ERRNO: Cell<c_int> = Cell::new(0);
|
||||
static ERRNO: Cell<c_int> = 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());
|
||||
|
@ -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(),
|
||||
);
|
||||
|
@ -144,6 +144,7 @@ unsafe impl<T> Send for MagicTag<T> {}
|
||||
|
||||
impl<T> MagicTag<T> {
|
||||
/// Create a new tag. See [`MagicSpec`] for its usage.
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub const fn new() -> Self {
|
||||
Self(ffi::MGVTBL::zero(), PhantomData)
|
||||
}
|
||||
|
@ -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<bool> = RefCell::new(false));
|
||||
thread_local!(static SERIALIZE_RAW: RefCell<bool> = const { RefCell::new(false) });
|
||||
|
||||
pub(crate) struct RawGuard(bool);
|
||||
|
||||
|
@ -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`].
|
||||
|
Loading…
Reference in New Issue
Block a user