From 2ce2d2d418ff4a55cf298cf28511252b93084c54 Mon Sep 17 00:00:00 2001 From: Peter Johnston Date: Wed, 29 May 2024 17:38:01 +0000 Subject: [PATCH] [netstack3] Remove workaround for associated type bounds Now that associated type bounds are stabilized in rustc (see https://github.com/rust-lang/rust/pull/122055), we can remove the workaround used in the IP crate to put filtering constraints on the device ID type. Change-Id: I80a9d6ce9553ff64f5f7a209dccb26d667a1753b Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1055952 Fuchsia-Auto-Submit: Peter Johnston Reviewed-by: Bruno Dal Bo Commit-Queue: Auto-Submit --- .../network/netstack3/core/ip/src/base.rs | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/connectivity/network/netstack3/core/ip/src/base.rs b/src/connectivity/network/netstack3/core/ip/src/base.rs index 05064b962f9..117fbf1f0a3 100644 --- a/src/connectivity/network/netstack3/core/ip/src/base.rs +++ b/src/connectivity/network/netstack3/core/ip/src/base.rs @@ -974,7 +974,7 @@ pub trait IpLayerIngressContext< I: IpLayerIpExt + IcmpHandlerIpExt, BC: IpLayerBindingsContext, >: - IpTransportDispatchContext + IpTransportDispatchContext> + IpDeviceStateContext + IpDeviceSendContext + IcmpErrorHandler @@ -983,20 +983,16 @@ pub trait IpLayerIngressContext< + FilterHandlerProvider + RawIpSocketHandler { - // This is working around the fact that currently, where clauses are only - // elaborated for supertraits, and not, for example, bounds on associated types - // as we have here. - // - // See https://github.com/rust-lang/rust/issues/20671#issuecomment-1905186183 - // for more discussion. - type DeviceId_: filter::InterfaceProperties + Debug; } impl< I: IpLayerIpExt + IcmpHandlerIpExt, BC: IpLayerBindingsContext, - CC: IpTransportDispatchContext - + IpDeviceStateContext + CC: IpTransportDispatchContext< + I, + BC, + DeviceId: filter::InterfaceProperties, + > + IpDeviceStateContext + IpDeviceSendContext + IcmpErrorHandler + IpLayerContext @@ -1004,36 +1000,26 @@ impl< + FilterHandlerProvider + RawIpSocketHandler, > IpLayerIngressContext for CC -where - Self::DeviceId: filter::InterfaceProperties, { - type DeviceId_ = Self::DeviceId; } /// A marker trait for all the contexts required for IP egress. pub(crate) trait IpLayerEgressContext: - IpDeviceSendContext + FilterHandlerProvider + IpDeviceSendContext> + + FilterHandlerProvider where I: IpLayerIpExt, BC: FilterBindingsContext, { - // This is working around the fact that currently, where clauses are only - // elaborated for supertraits, and not, for example, bounds on associated types - // as we have here. - // - // See https://github.com/rust-lang/rust/issues/20671#issuecomment-1905186183 - // for more discussion. - type DeviceId_: filter::InterfaceProperties + StrongDeviceIdentifier + Debug; } impl IpLayerEgressContext for CC where I: IpLayerIpExt, BC: FilterBindingsContext, - CC: IpDeviceSendContext + FilterHandlerProvider, - Self::DeviceId: filter::InterfaceProperties, + CC: IpDeviceSendContext> + + FilterHandlerProvider, { - type DeviceId_ = Self::DeviceId; } /// A builder for IPv4 state.