From 1e5c32ca60d535704467a1765429d6ec28f4b409 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 6 Nov 2023 11:21:26 +0800 Subject: [PATCH] style(napi): fix compile warning (#1785) --- crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs | 7 +++---- crates/napi/src/bindgen_runtime/js_values/buffer.rs | 7 +++---- crates/napi/src/bindgen_runtime/module_register.rs | 9 +++++++-- crates/sys/src/functions.rs | 1 + crates/sys/src/lib.rs | 3 +++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs index ae2d4145..01ee9c76 100644 --- a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs +++ b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs @@ -80,12 +80,11 @@ macro_rules! impl_typed_array { if ref_.is_null() { return; } - #[cfg(not(target_os = "wasi"))] - if CUSTOM_GC_TSFN_DESTROYED.load(Ordering::SeqCst) { - return; - } #[cfg(all(feature = "napi4", not(target_os = "wasi")))] { + if CUSTOM_GC_TSFN_DESTROYED.load(Ordering::SeqCst) { + return; + } if !THREADS_CAN_ACCESS_ENV .borrow_mut(|m| m.get(&std::thread::current().id()).is_some()) { diff --git a/crates/napi/src/bindgen_runtime/js_values/buffer.rs b/crates/napi/src/bindgen_runtime/js_values/buffer.rs index b710845d..7d3347f2 100644 --- a/crates/napi/src/bindgen_runtime/js_values/buffer.rs +++ b/crates/napi/src/bindgen_runtime/js_values/buffer.rs @@ -37,12 +37,11 @@ impl Drop for Buffer { if ref_.is_null() { return; } - #[cfg(not(target_os = "wasi"))] - if CUSTOM_GC_TSFN_DESTROYED.load(std::sync::atomic::Ordering::SeqCst) { - return; - } #[cfg(all(feature = "napi4", not(target_os = "wasi")))] { + if CUSTOM_GC_TSFN_DESTROYED.load(std::sync::atomic::Ordering::SeqCst) { + return; + } if !THREADS_CAN_ACCESS_ENV.borrow_mut(|m| m.get(&std::thread::current().id()).is_some()) { let status = unsafe { sys::napi_call_threadsafe_function( diff --git a/crates/napi/src/bindgen_runtime/module_register.rs b/crates/napi/src/bindgen_runtime/module_register.rs index cb4fc193..2dbdd090 100644 --- a/crates/napi/src/bindgen_runtime/module_register.rs +++ b/crates/napi/src/bindgen_runtime/module_register.rs @@ -1,13 +1,18 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; +#[cfg(not(feature = "noop"))] +use std::collections::HashSet; use std::ffi::CStr; use std::ptr; +#[cfg(all(feature = "napi4", not(target_os = "wasi")))] +use std::sync::atomic::AtomicPtr; #[cfg(all( any(target_os = "windows", target_os = "freebsd"), feature = "napi4", feature = "tokio_rt" ))] use std::sync::atomic::AtomicUsize; -use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; +#[cfg(not(feature = "noop"))] +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::RwLock; use std::thread::ThreadId; diff --git a/crates/sys/src/functions.rs b/crates/sys/src/functions.rs index eafdb768..d4a39f83 100644 --- a/crates/sys/src/functions.rs +++ b/crates/sys/src/functions.rs @@ -761,6 +761,7 @@ mod experimental { #[cfg(feature = "experimental")] pub use experimental::*; + pub use napi1::*; #[cfg(feature = "napi2")] pub use napi2::*; diff --git a/crates/sys/src/lib.rs b/crates/sys/src/lib.rs index 9a29ae3e..20ae54fe 100644 --- a/crates/sys/src/lib.rs +++ b/crates/sys/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(ambiguous_glob_reexports)] + #[cfg(windows)] macro_rules! generate { (extern "C" { @@ -30,6 +32,7 @@ macro_rules! generate { } }; + #[allow(clippy::missing_safety_doc)] pub unsafe fn load( host: &libloading::Library, ) -> Result<(), libloading::Error> {