From 54f97c967b194446438a4ea1e899dfd9d2e72cf9 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Sun, 8 Dec 2024 09:35:37 +0100 Subject: [PATCH] Limit scope of `allow(coherence_leak_check)` (#4339) --- src/closure.rs | 2 ++ src/convert/closures.rs | 12 ++++++++---- src/lib.rs | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/closure.rs b/src/closure.rs index 95cf2250a89..d5107c34ec9 100644 --- a/src/closure.rs +++ b/src/closure.rs @@ -561,6 +561,7 @@ macro_rules! doit { ($( ($($var:ident $arg1:ident $arg2:ident $arg3:ident $arg4:ident)*) )*) => ($( + #[allow(coherence_leak_check)] unsafe impl<$($var,)* R> WasmClosure for dyn Fn($($var),*) -> R + 'static where $($var: FromWasmAbi + 'static,)* R: ReturnWasmAbi + 'static, @@ -620,6 +621,7 @@ macro_rules! doit { } } + #[allow(coherence_leak_check)] unsafe impl<$($var,)* R> WasmClosure for dyn FnMut($($var),*) -> R + 'static where $($var: FromWasmAbi + 'static,)* R: ReturnWasmAbi + 'static, diff --git a/src/convert/closures.rs b/src/convert/closures.rs index 1f45f90f58b..536ca686d0a 100644 --- a/src/convert/closures.rs +++ b/src/convert/closures.rs @@ -10,7 +10,8 @@ use crate::throw_str; macro_rules! stack_closures { ($( ($cnt:tt $invoke:ident $invoke_mut:ident $($var:ident $arg1:ident $arg2:ident $arg3:ident $arg4:ident)*) )*) => ($( - impl<'a, 'b, $($var,)* R> IntoWasmAbi for &'a (dyn Fn($($var),*) -> R + 'b) + #[allow(coherence_leak_check)] + impl<$($var,)* R> IntoWasmAbi for &'_ (dyn Fn($($var),*) -> R + '_) where $($var: FromWasmAbi,)* R: ReturnWasmAbi { @@ -50,7 +51,8 @@ macro_rules! stack_closures { ret.return_abi().into() } - impl<'a, $($var,)* R> WasmDescribe for dyn Fn($($var),*) -> R + 'a + #[allow(coherence_leak_check)] + impl<$($var,)* R> WasmDescribe for dyn Fn($($var),*) -> R + '_ where $($var: FromWasmAbi,)* R: ReturnWasmAbi { @@ -65,7 +67,8 @@ macro_rules! stack_closures { } } - impl<'a, 'b, $($var,)* R> IntoWasmAbi for &'a mut (dyn FnMut($($var),*) -> R + 'b) + #[allow(coherence_leak_check)] + impl<$($var,)* R> IntoWasmAbi for &'_ mut (dyn FnMut($($var),*) -> R + '_) where $($var: FromWasmAbi,)* R: ReturnWasmAbi { @@ -105,7 +108,8 @@ macro_rules! stack_closures { ret.return_abi().into() } - impl<'a, $($var,)* R> WasmDescribe for dyn FnMut($($var),*) -> R + 'a + #[allow(coherence_leak_check)] + impl<$($var,)* R> WasmDescribe for dyn FnMut($($var),*) -> R + '_ where $($var: FromWasmAbi,)* R: ReturnWasmAbi { diff --git a/src/lib.rs b/src/lib.rs index b4e5a6a9b1f..3aac1273ae7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,6 @@ feature(allow_internal_unstable), allow(internal_features) )] -#![allow(coherence_leak_check)] #![doc(html_root_url = "https://docs.rs/wasm-bindgen/0.2")] extern crate alloc;