From b48a7578371c7f9353f35a95ca1c965165ac1a39 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 5 Mar 2022 21:29:57 +0800 Subject: [PATCH] style: clippy fix --- crates/napi/src/bindgen_runtime/callback_info.rs | 1 + crates/napi/src/error.rs | 1 + crates/napi/src/js_values/escapable_handle_scope.rs | 6 +++--- crates/napi/src/threadsafe_function.rs | 2 +- crates/napi/src/tokio_runtime.rs | 1 + examples/napi/src/class.rs | 2 ++ examples/napi/src/js_mod.rs | 1 + 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/napi/src/bindgen_runtime/callback_info.rs b/crates/napi/src/bindgen_runtime/callback_info.rs index 50409046..eb79236a 100644 --- a/crates/napi/src/bindgen_runtime/callback_info.rs +++ b/crates/napi/src/bindgen_runtime/callback_info.rs @@ -17,6 +17,7 @@ pub struct CallbackInfo { } impl CallbackInfo { + #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn new( env: sys::napi_env, callback_info: sys::napi_callback_info, diff --git a/crates/napi/src/error.rs b/crates/napi/src/error.rs index fde8fa48..8228cce8 100644 --- a/crates/napi/src/error.rs +++ b/crates/napi/src/error.rs @@ -213,6 +213,7 @@ macro_rules! impl_object_methods { ); } + #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn throw(&self, env: sys::napi_env) -> Result<()> { let error_status = format!("{:?}\0", self.0.status); let status_len = error_status.len(); diff --git a/crates/napi/src/js_values/escapable_handle_scope.rs b/crates/napi/src/js_values/escapable_handle_scope.rs index e035609c..2e186455 100644 --- a/crates/napi/src/js_values/escapable_handle_scope.rs +++ b/crates/napi/src/js_values/escapable_handle_scope.rs @@ -10,12 +10,12 @@ pub struct EscapableHandleScope { } impl EscapableHandleScope { - pub fn open(env: sys::napi_env, value: T) -> Result { + pub fn open(env: Env, value: T) -> Result { let mut handle_scope = ptr::null_mut(); - check_status!(unsafe { sys::napi_open_escapable_handle_scope(env, &mut handle_scope) })?; + check_status!(unsafe { sys::napi_open_escapable_handle_scope(env.0, &mut handle_scope) })?; let mut result = ptr::null_mut(); check_status!(unsafe { - sys::napi_escape_handle(env, handle_scope, NapiRaw::raw(&value), &mut result) + sys::napi_escape_handle(env.0, handle_scope, NapiRaw::raw(&value), &mut result) })?; Ok(Self { handle_scope, diff --git a/crates/napi/src/threadsafe_function.rs b/crates/napi/src/threadsafe_function.rs index 4a0848c5..025028ad 100644 --- a/crates/napi/src/threadsafe_function.rs +++ b/crates/napi/src/threadsafe_function.rs @@ -175,7 +175,7 @@ unsafe impl Sync for ThreadsafeFunction {} impl ThreadsafeFunction { /// See [napi_create_threadsafe_function](https://nodejs.org/api/n-api.html#n_api_napi_create_threadsafe_function) /// for more information. - pub fn create< + pub(crate) fn create< V: NapiRaw, R: 'static + Send + FnMut(ThreadSafeCallContext) -> Result>, >( diff --git a/crates/napi/src/tokio_runtime.rs b/crates/napi/src/tokio_runtime.rs index 133d66e0..abd7931d 100644 --- a/crates/napi/src/tokio_runtime.rs +++ b/crates/napi/src/tokio_runtime.rs @@ -61,6 +61,7 @@ where RT.0.spawn(fut); } +#[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn execute_tokio_future< Data: 'static + Send, Fut: 'static + Send + Future>, diff --git a/examples/napi/src/class.rs b/examples/napi/src/class.rs index c909d627..8d1a2a98 100644 --- a/examples/napi/src/class.rs +++ b/examples/napi/src/class.rs @@ -212,6 +212,7 @@ pub struct JsAssets {} #[napi] impl JsAssets { #[napi(constructor)] + #[allow(clippy::new_without_default)] pub fn new() -> Self { JsAssets {} } @@ -228,6 +229,7 @@ pub struct JsAsset {} #[napi] impl JsAsset { #[napi(constructor)] + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self {} } diff --git a/examples/napi/src/js_mod.rs b/examples/napi/src/js_mod.rs index 5c812567..a659fde9 100644 --- a/examples/napi/src/js_mod.rs +++ b/examples/napi/src/js_mod.rs @@ -33,6 +33,7 @@ mod xxh3 { #[napi] impl Xxh3 { #[napi(constructor)] + #[allow(clippy::new_without_default)] pub fn new() -> Xxh3 { Xxh3 { inner: BigInt {