From a98129daae2f07bb586671fc2aa749a950617133 Mon Sep 17 00:00:00 2001 From: Pierre Tondereau Date: Wed, 25 Oct 2023 17:39:22 +0200 Subject: [PATCH] correct clippy and stuff --- crates/macros/src/function.rs | 4 ++-- crates/macros/src/impl_.rs | 2 +- examples/hello_world.rs | 17 +++-------------- src/builders/module.rs | 1 - src/internal/mod.rs | 1 + tests/module.rs | 4 ++-- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/crates/macros/src/function.rs b/crates/macros/src/function.rs index 4236e48280..41960b8281 100644 --- a/crates/macros/src/function.rs +++ b/crates/macros/src/function.rs @@ -375,10 +375,10 @@ impl<'a> Args<'a> { syn::Pat::Ident(syn::PatIdent { ident, .. }) => ident, _ => bail!(pat => "Unsupported argument."), }; - let nullable = type_is_nullable(&**ty)?; + let nullable = type_is_nullable(ty)?; result.typed.push(TypedArg { name: ident, - ty: &**ty, + ty, nullable, default: defaults.remove(ident), }); diff --git a/crates/macros/src/impl_.rs b/crates/macros/src/impl_.rs index 0904da1855..58860e82f4 100644 --- a/crates/macros/src/impl_.rs +++ b/crates/macros/src/impl_.rs @@ -38,7 +38,7 @@ pub struct ImplArgs { } /// Different types of rename rules for methods. -#[derive(Debug, Copy, Clone, FromMeta)] +#[derive(Debug, Default, Copy, Clone, FromMeta)] pub enum RenameRule { /// Methods won't be renamed. #[darling(rename = "none")] diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 1c59595299..0b73beb8a1 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -1,15 +1,4 @@ -use ext_php_rs::{ - args::Arg, - builders::{ClassBuilder, FunctionBuilder, ModuleStartup}, - class::{ClassMetadata, ConstructorMeta, ConstructorResult, RegisteredClass}, - constant::IntoConst, - convert::IntoZval, - flags::DataType, - internal::class::{PhpClassImpl, PhpClassImplCollector}, - prelude::*, - types::{ZendClassObject, Zval}, - zend::ExecuteData, -}; +use ext_php_rs::{constant::IntoConst, prelude::*, types::ZendClassObject}; #[derive(Debug)] #[php_class] @@ -75,12 +64,12 @@ pub struct TestZvalConvert<'a> { } #[php_function] -pub fn get_zval_convert<'a>(z: TestZvalConvert<'a>) -> i32 { +pub fn get_zval_convert(z: TestZvalConvert) -> i32 { dbg!(z); 5 } -fn startup(ty: i32, mod_num: i32) -> i32 { +fn startup(_ty: i32, mod_num: i32) -> i32 { 5.register_constant("SOME_CONST", mod_num).unwrap(); 0 } diff --git a/src/builders/module.rs b/src/builders/module.rs index 6fe83e2544..2137c9edc8 100644 --- a/src/builders/module.rs +++ b/src/builders/module.rs @@ -4,7 +4,6 @@ use crate::{ constant::IntoConst, error::Result, ffi::{ext_php_rs_php_build_id, ZEND_MODULE_API_NO}, - flags::MethodFlags, zend::{FunctionEntry, ModuleEntry}, PHP_DEBUG, PHP_ZTS, }; diff --git a/src/internal/mod.rs b/src/internal/mod.rs index b2209df249..5afbc7b1ee 100644 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -12,6 +12,7 @@ pub type ModuleStartupMutex = Mutex>; /// The initialisation value for [`ModuleStartupMutex`]. By default the mutex /// contains [`None`]. +#[allow(clippy::declare_interior_mutable_const)] pub const MODULE_STARTUP_INIT: ModuleStartupMutex = const_mutex(None); /// Called by startup functions registered with the [`#[php_startup]`] macro. diff --git a/tests/module.rs b/tests/module.rs index f1ef22b852..0d7296f9ed 100644 --- a/tests/module.rs +++ b/tests/module.rs @@ -39,6 +39,6 @@ pub fn hello_world(name: String) -> String { } #[php_module] -pub fn module(module: ModuleBuilder) -> ModuleBuilder { - module +pub fn get_module(module: ModuleBuilder) -> ModuleBuilder { + module.function(wrap_function!(hello_world)) }