From 2973b01bf5fe3963b1a1281c3f9ea6bf69130228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 2 Dec 2025 20:37:52 +0100 Subject: [PATCH] Use `const` block instead of trait trick in `subscription` --- futures/src/subscription.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/futures/src/subscription.rs b/futures/src/subscription.rs index d14724f5..18e6cdd9 100644 --- a/futures/src/subscription.rs +++ b/futures/src/subscription.rs @@ -306,7 +306,9 @@ impl Subscription { F: Fn(T) -> A + MaybeSend + Clone + 'static, A: 'static, { - F::assert_zero_size(); + const { + check_zero_sized::(); + } struct Map where @@ -363,7 +365,9 @@ impl Subscription { F: Fn(T) -> Option + MaybeSend + Clone + 'static, A: MaybeSend + 'static, { - F::assert_zero_size(); + const { + check_zero_sized::(); + } struct FilterMap where @@ -522,17 +526,6 @@ where } } -trait PanicWhenNotZeroSized: Sized { - const _CHECK: () = check_zero_sized::(); - - #[allow(path_statements, clippy::no_effect)] - fn assert_zero_size() { - ::_CHECK; - } -} - -impl PanicWhenNotZeroSized for T {} - const fn check_zero_sized() { if std::mem::size_of::() != 0 { panic!(