Skip to content

Commit 58a74ea

Browse files
feat(crabnet): fix warnings and test regression
* Remove the pointer extension trait for `NonNull` as of the `non_null_convenience` feature. CC: rust-lang/rust#117691 * Update the test stderr files, to match with the new error style. Signed-off-by: Anhad Singh <[email protected]>
1 parent 3e5d0a2 commit 58a74ea

File tree

5 files changed

+12
-29
lines changed

5 files changed

+12
-29
lines changed

src/lib.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![no_std]
2-
#![feature(allocator_api, trivial_bounds, new_uninit, associated_type_defaults)]
2+
#![feature(
3+
non_null_convenience,
4+
allocator_api,
5+
trivial_bounds,
6+
new_uninit,
7+
associated_type_defaults
8+
)]
39

410
extern crate alloc;
511

@@ -91,23 +97,6 @@ where
9197
fn into_boxed_bytes_in<A: Allocator>(self, alloc: A) -> Box<[u8], A>;
9298
}
9399

94-
trait PointerExtension {
95-
unsafe fn add(self, count: usize) -> Self;
96-
unsafe fn sub(self, count: usize) -> Self;
97-
}
98-
99-
impl<T> PointerExtension for NonNull<T> {
100-
#[inline]
101-
unsafe fn add(self, count: usize) -> Self {
102-
NonNull::new_unchecked(self.as_ptr().add(count))
103-
}
104-
105-
#[inline]
106-
unsafe fn sub(self, count: usize) -> Self {
107-
NonNull::new_unchecked(self.as_ptr().sub(count))
108-
}
109-
}
110-
111100
// impl for [T; N]
112101
unsafe impl<const N: usize, T> StackingAnchor<[T; N]> for [T; N] {}
113102
unsafe impl<const N: usize, T, U: Protocol> StackingAnchor<[T; N]> for crate::Stacked<U, [T; N]> {}

src/transport/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use byte_endian::BigEndian;
55
use static_assertions::const_assert_eq;
66

77
use crate::network::Ipv4;
8-
use crate::{Parsable, Parsed, PointerExtension, Protocol, Stack, Stacked, StackingAnchor};
8+
use crate::{Parsable, Parsed, Protocol, Stack, Stacked, StackingAnchor};
99

1010
#[derive(Default, Debug, Copy, Clone, PartialEq)]
1111
#[repr(transparent)]

src/transport/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use byte_endian::BigEndian;
22
use static_assertions::const_assert_eq;
33

44
use crate::network::Ipv4;
5-
use crate::{Parsable, PointerExtension, Protocol, Stack, Stacked, StackingAnchor};
5+
use crate::{Parsable, Protocol, Stack, Stacked, StackingAnchor};
66

77
#[repr(C, packed)]
88
pub struct Udp {

tests/ui/udp_no_parent.stderr

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ error[E0599]: the method `into_boxed_bytes` exists for struct `Stacked<Udp, [u8;
77
::: src/lib.rs
88
|
99
| pub struct Stacked<U: Protocol, L: Protocol> {
10-
| --------------------------------------------
11-
| |
12-
| doesn't satisfy `_: IntoBoxedBytes`
13-
| doesn't satisfy `_: IsSafeToWrite`
10+
| -------------------------------------------- doesn't satisfy `_: IntoBoxedBytes` or `_: IsSafeToWrite`
1411
|
1512
= note: the following trait bounds were not satisfied:
1613
`Stacked<crabnet::transport::Udp, [u8; 4]>: IsSafeToWrite`
@@ -29,10 +26,7 @@ error[E0599]: the method `into_boxed_bytes` exists for struct `Udp`, but its tra
2926
::: src/transport/udp.rs
3027
|
3128
| pub struct Udp {
32-
| --------------
33-
| |
34-
| doesn't satisfy `crabnet::transport::Udp: IntoBoxedBytes`
35-
| doesn't satisfy `crabnet::transport::Udp: IsSafeToWrite`
29+
| -------------- doesn't satisfy `crabnet::transport::Udp: IntoBoxedBytes` or `crabnet::transport::Udp: IsSafeToWrite`
3630
|
3731
= note: the following trait bounds were not satisfied:
3832
`crabnet::transport::Udp: IsSafeToWrite`

tests/ui/valid_parent.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `Eth: StackingAnchor<Ipv4>` is not satisfied
22
--> tests/ui/valid_parent.rs:8:17
33
|
44
8 | let x = eth / udp;
5-
| ^ the trait `StackingAnchor<Ipv4>` is not implemented for `Eth`
5+
| ^ the trait `StackingAnchor<Ipv4>` is not implemented for `Eth`, which is required by `Eth: Div<_>`
66
|
77
= help: the trait `StackingAnchor<Eth>` is implemented for `Eth`
88
= help: for that trait implementation, expected `Eth`, found `Ipv4`

0 commit comments

Comments
 (0)