Skip to content

Commit

Permalink
[netstack3] Remove workaround for associated type bounds
Browse files Browse the repository at this point in the history
Now that associated type bounds are stabilized in rustc (see
rust-lang/rust#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 <[email protected]>
Reviewed-by: Bruno Dal Bo <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
peterthejohnston authored and CQ Bot committed May 29, 2024
1 parent 9e4a3af commit 2ce2d2d
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions src/connectivity/network/netstack3/core/ip/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 974,7 @@ pub trait IpLayerIngressContext<
I: IpLayerIpExt IcmpHandlerIpExt,
BC: IpLayerBindingsContext<I, Self::DeviceId>,
>:
IpTransportDispatchContext<I, BC, DeviceId = Self::DeviceId_>
IpTransportDispatchContext<I, BC, DeviceId: filter::InterfaceProperties<BC::DeviceClass>>
IpDeviceStateContext<I, BC>
IpDeviceSendContext<I, BC>
IcmpErrorHandler<I, BC>
Expand All @@ -983,57 983,43 @@ pub trait IpLayerIngressContext<
FilterHandlerProvider<I, BC>
RawIpSocketHandler<I, BC>
{
// 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<BC::DeviceClass> Debug;
}

impl<
I: IpLayerIpExt IcmpHandlerIpExt,
BC: IpLayerBindingsContext<I, CC::DeviceId>,
CC: IpTransportDispatchContext<I, BC>
IpDeviceStateContext<I, BC>
CC: IpTransportDispatchContext<
I,
BC,
DeviceId: filter::InterfaceProperties<BC::DeviceClass>,
> IpDeviceStateContext<I, BC>
IpDeviceSendContext<I, BC>
IcmpErrorHandler<I, BC>
IpLayerContext<I, BC>
FragmentHandler<I, BC>
FilterHandlerProvider<I, BC>
RawIpSocketHandler<I, BC>,
> IpLayerIngressContext<I, BC> for CC
where
Self::DeviceId: filter::InterfaceProperties<BC::DeviceClass>,
{
type DeviceId_ = Self::DeviceId;
}

/// A marker trait for all the contexts required for IP egress.
pub(crate) trait IpLayerEgressContext<I, BC>:
IpDeviceSendContext<I, BC, DeviceId = Self::DeviceId_> FilterHandlerProvider<I, BC>
IpDeviceSendContext<I, BC, DeviceId: filter::InterfaceProperties<BC::DeviceClass>>
FilterHandlerProvider<I, BC>
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<BC::DeviceClass> StrongDeviceIdentifier Debug;
}

impl<I, BC, CC> IpLayerEgressContext<I, BC> for CC
where
I: IpLayerIpExt,
BC: FilterBindingsContext,
CC: IpDeviceSendContext<I, BC> FilterHandlerProvider<I, BC>,
Self::DeviceId: filter::InterfaceProperties<BC::DeviceClass>,
CC: IpDeviceSendContext<I, BC, DeviceId: filter::InterfaceProperties<BC::DeviceClass>>
FilterHandlerProvider<I, BC>,
{
type DeviceId_ = Self::DeviceId;
}

/// A builder for IPv4 state.
Expand Down

0 comments on commit 2ce2d2d

Please sign in to comment.