From cd740c9bd0d3678775fc86b97a5f23cfd1e029b4 Mon Sep 17 00:00:00 2001 From: "K.J. Valencik" Date: Fri, 17 Nov 2023 09:50:40 -0500 Subject: [PATCH 1/2] Clippy fixes --- crates/neon/src/handle/mod.rs | 5 +---- crates/neon/src/types_impl/boxed.rs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/neon/src/handle/mod.rs b/crates/neon/src/handle/mod.rs index 06fb134cf..2994e9998 100644 --- a/crates/neon/src/handle/mod.rs +++ b/crates/neon/src/handle/mod.rs @@ -80,10 +80,7 @@ pub struct Handle<'a, V: Value + 'a> { impl<'a, V: Value> Clone for Handle<'a, V> { fn clone(&self) -> Self { - Self { - value: self.value, - phantom: PhantomData, - } + *self } } diff --git a/crates/neon/src/types_impl/boxed.rs b/crates/neon/src/types_impl/boxed.rs index 4306bbed5..990ce83cf 100644 --- a/crates/neon/src/types_impl/boxed.rs +++ b/crates/neon/src/types_impl/boxed.rs @@ -164,10 +164,7 @@ unsafe fn maybe_external_deref<'a>(env: Env, local: raw::Local) -> Option<&'a Bo // Custom `Clone` implementation since `T` might not be `Clone` impl Clone for JsBoxInner { fn clone(&self) -> Self { - Self { - local: self.local, - raw_data: self.raw_data, - } + *self } } From f8cedab66f796f4b1c7d4db7dc9b58c7446203d6 Mon Sep 17 00:00:00 2001 From: "K.J. Valencik" Date: Mon, 27 Nov 2023 12:32:27 -0500 Subject: [PATCH 2/2] Avoid leaving a dangling future when handling a rejection in JsPromise::to_future --- crates/neon/src/types_impl/promise.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/neon/src/types_impl/promise.rs b/crates/neon/src/types_impl/promise.rs index 9cf5b0285..e523e6f38 100644 --- a/crates/neon/src/types_impl/promise.rs +++ b/crates/neon/src/types_impl/promise.rs @@ -186,7 +186,6 @@ impl JsPromise { + 'static, { let then = self.get::(cx, "then")?; - let catch = self.get::(cx, "catch")?; let (tx, rx) = oneshot::channel(); let take_state = { @@ -235,8 +234,11 @@ impl JsPromise { } })?; - then.exec(cx, Handle::new_internal(Self(self.0)), [resolve.upcast()])?; - catch.exec(cx, Handle::new_internal(Self(self.0)), [reject.upcast()])?; + then.exec( + cx, + Handle::new_internal(Self(self.0)), + [resolve.upcast(), reject.upcast()], + )?; Ok(JsFuture { rx }) }