style(napi): fix compile warning (#1785)

This commit is contained in:
LongYinan 2023-11-06 11:21:26 +08:00 committed by GitHub
parent feabcd7f16
commit 1e5c32ca60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 10 deletions

View file

@ -80,12 +80,11 @@ macro_rules! impl_typed_array {
if ref_.is_null() { if ref_.is_null() {
return; return;
} }
#[cfg(not(target_os = "wasi"))]
if CUSTOM_GC_TSFN_DESTROYED.load(Ordering::SeqCst) {
return;
}
#[cfg(all(feature = "napi4", not(target_os = "wasi")))] #[cfg(all(feature = "napi4", not(target_os = "wasi")))]
{ {
if CUSTOM_GC_TSFN_DESTROYED.load(Ordering::SeqCst) {
return;
}
if !THREADS_CAN_ACCESS_ENV if !THREADS_CAN_ACCESS_ENV
.borrow_mut(|m| m.get(&std::thread::current().id()).is_some()) .borrow_mut(|m| m.get(&std::thread::current().id()).is_some())
{ {

View file

@ -37,12 +37,11 @@ impl Drop for Buffer {
if ref_.is_null() { if ref_.is_null() {
return; 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")))] #[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()) { if !THREADS_CAN_ACCESS_ENV.borrow_mut(|m| m.get(&std::thread::current().id()).is_some()) {
let status = unsafe { let status = unsafe {
sys::napi_call_threadsafe_function( sys::napi_call_threadsafe_function(

View file

@ -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::ffi::CStr;
use std::ptr; use std::ptr;
#[cfg(all(feature = "napi4", not(target_os = "wasi")))]
use std::sync::atomic::AtomicPtr;
#[cfg(all( #[cfg(all(
any(target_os = "windows", target_os = "freebsd"), any(target_os = "windows", target_os = "freebsd"),
feature = "napi4", feature = "napi4",
feature = "tokio_rt" feature = "tokio_rt"
))] ))]
use std::sync::atomic::AtomicUsize; 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::sync::RwLock;
use std::thread::ThreadId; use std::thread::ThreadId;

View file

@ -761,6 +761,7 @@ mod experimental {
#[cfg(feature = "experimental")] #[cfg(feature = "experimental")]
pub use experimental::*; pub use experimental::*;
pub use napi1::*; pub use napi1::*;
#[cfg(feature = "napi2")] #[cfg(feature = "napi2")]
pub use napi2::*; pub use napi2::*;

View file

@ -1,3 +1,5 @@
#![allow(ambiguous_glob_reexports)]
#[cfg(windows)] #[cfg(windows)]
macro_rules! generate { macro_rules! generate {
(extern "C" { (extern "C" {
@ -30,6 +32,7 @@ macro_rules! generate {
} }
}; };
#[allow(clippy::missing_safety_doc)]
pub unsafe fn load( pub unsafe fn load(
host: &libloading::Library, host: &libloading::Library,
) -> Result<(), libloading::Error> { ) -> Result<(), libloading::Error> {