Skip to content

Commit 308fa11

Browse files
authored
New clippy configuration (#741)
1 parent 8dcb4a1 commit 308fa11

File tree

175 files changed

+1425
-1333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+1425
-1333
lines changed

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ license = "MIT OR Apache-2.0"
2525
edition = "2024"
2626
rust-version = "1.86"
2727

28+
[workspace.lints.rust]
29+
async_fn_in_trait = { level = "allow", priority = -1 }
30+
rust_2018_idioms = "deny"
31+
warnings = "deny"
32+
unreachable_pub = "deny"
33+
missing_debug_implementations = "deny"
34+
35+
unexpected_cfgs = { level = "warn", priority = -2, check-cfg = ['cfg(docsrs_dep)'] }
36+
2837
[patch.crates-io]
2938
ntex = { path = "ntex" }
3039
ntex-bytes = { path = "ntex-bytes" }
@@ -42,12 +51,12 @@ ntex-macros = { path = "ntex-macros" }
4251
ntex-util = { path = "ntex-util" }
4352

4453
[workspace.dependencies]
45-
ntex = "3.0.0"
46-
ntex-bytes = "1.4.1"
54+
ntex = "3.0.1"
55+
ntex-bytes = "1.5.0"
4756
ntex-codec = "1.1.0"
4857
ntex-io = "3.7.1"
4958
ntex-dispatcher = "3.0.0"
50-
ntex-net = "3.6.0"
59+
ntex-net = "3.6.1"
5160
ntex-http = "1.0.0"
5261
ntex-router = "1.0.0"
5362
ntex-rt = "3.6.0"

ntex-bytes/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## [1.5.0] (2026-02-03)
4+
5+
* Add AsMut impl for UninitSlice
6+
37
## [1.4.1] (2026-01-22)
48

59
* Allow only u32 ref counts

ntex-bytes/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ntex-bytes"
3-
version = "1.4.1"
3+
version = "1.5.0"
44
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
55
description = "Types and traits for working with bytes (bytes crate fork)"
66
documentation = "https://docs.rs/ntex-bytes"
@@ -9,7 +9,7 @@ readme = "README.md"
99
keywords = ["buffers", "zero-copy", "io"]
1010
categories = ["network-programming", "data-structures"]
1111
edition = "2024"
12-
rust-version = "1.86"
12+
rust-version = "1.88"
1313
license = "MIT OR Apache-2.0"
1414

1515
[features]
@@ -18,6 +18,9 @@ default = []
1818
# simd utf8 check support
1919
simd = ["simdutf8"]
2020

21+
[lints]
22+
workspace = true
23+
2124
[dependencies]
2225
bytes = { workspace = true }
2326
serde = { workspace = true }

ntex-bytes/src/buf/buf_impl.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ macro_rules! buf_get_impl {
66
// try to convert directly from the bytes
77
// this Option<ret> trick is to avoid keeping a borrow on self
88
// when advance() is called (mut borrow) and to call bytes() only once
9-
let ret = $this
10-
.chunk()
11-
.get(..SIZE)
12-
.map(|src| unsafe { $typ::$conv(*(src as *const _ as *const [_; SIZE])) });
9+
#[allow(clippy::ptr_as_ptr)]
10+
let ret = $this.chunk().get(..SIZE).map(|src| unsafe {
11+
$typ::$conv(*(std::ptr::from_ref(src) as *const [_; SIZE]))
12+
});
1313

1414
if let Some(ret) = ret {
1515
// if the direct conversion was possible, advance and return
1616
$this.advance(SIZE);
1717
return ret;
18-
} else {
19-
// if not we copy the bytes in a temp buffer then convert
20-
let mut buf = [0; SIZE];
21-
$this.copy_to_slice(&mut buf); // (do the advance)
22-
return $typ::$conv(buf);
2318
}
19+
// if not we copy the bytes in a temp buffer then convert
20+
let mut buf = [0; SIZE];
21+
$this.copy_to_slice(&mut buf); // (do the advance)
22+
return $typ::$conv(buf);
2423
}};
2524
(le => $this:ident, $typ:tt, $len_to_read:expr) => {{
2625
debug_assert!(mem::size_of::<$typ>() >= $len_to_read);
@@ -804,7 +803,7 @@ impl<T: Buf + ?Sized> Buf for &mut T {
804803

805804
#[inline]
806805
fn advance(&mut self, cnt: usize) {
807-
(**self).advance(cnt)
806+
(**self).advance(cnt);
808807
}
809808
}
810809

@@ -820,7 +819,7 @@ impl<T: Buf + ?Sized> Buf for Box<T> {
820819
}
821820

822821
fn advance(&mut self, cnt: usize) {
823-
(**self).advance(cnt)
822+
(**self).advance(cnt);
824823
}
825824
}
826825

@@ -896,6 +895,7 @@ impl<T: AsRef<[u8]>> Buf for std::io::Cursor<T> {
896895
fn _assert_trait_object(_b: &dyn Buf) {}
897896

898897
#[cfg(test)]
898+
#[allow(clippy::float_cmp)]
899899
mod tests {
900900
use super::*;
901901

@@ -950,56 +950,56 @@ mod tests {
950950
assert_eq!(0x0809, buf.get_i16_le());
951951

952952
let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];
953-
assert_eq!(0x0809A0A1, buf.get_u32());
953+
assert_eq!(0x0809_A0A1, buf.get_u32());
954954

955955
let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];
956-
assert_eq!(0x0809A0A1, buf.get_u32_le());
956+
assert_eq!(0x0809_A0A1, buf.get_u32_le());
957957

958958
let mut buf = &b"\x08\x09\xA0\xA1 hello"[..];
959-
assert_eq!(0x0809A0A1, buf.get_i32());
959+
assert_eq!(0x0809_A0A1, buf.get_i32());
960960

961961
let mut buf = &b"\xA1\xA0\x09\x08 hello"[..];
962-
assert_eq!(0x0809A0A1, buf.get_i32_le());
962+
assert_eq!(0x0809_A0A1, buf.get_i32_le());
963963

964964
let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];
965-
assert_eq!(0x0102030405060708, buf.get_u64());
965+
assert_eq!(0x0102_0304_0506_0708, buf.get_u64());
966966

967967
let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
968-
assert_eq!(0x0102030405060708, buf.get_u64_le());
968+
assert_eq!(0x0102_0304_0506_0708, buf.get_u64_le());
969969

970970
let mut buf = &b"\x01\x02\x03\x04\x05\x06\x07\x08 hello"[..];
971-
assert_eq!(0x0102030405060708, buf.get_i64());
971+
assert_eq!(0x0102_0304_0506_0708, buf.get_i64());
972972

973973
let mut buf = &b"\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
974-
assert_eq!(0x0102030405060708, buf.get_i64_le());
974+
assert_eq!(0x0102_0304_0506_0708, buf.get_i64_le());
975975

976976
let mut buf =
977977
&b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];
978-
assert_eq!(0x01020304050607080910111213141516, buf.get_u128());
978+
assert_eq!(0x0102_0304_0506_0708_0910_1112_1314_1516, buf.get_u128());
979979

980980
let mut buf =
981981
&b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
982-
assert_eq!(0x01020304050607080910111213141516, buf.get_u128_le());
982+
assert_eq!(0x0102_0304_0506_0708_0910_1112_1314_1516, buf.get_u128_le());
983983

984984
let mut buf =
985985
&b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16 hello"[..];
986-
assert_eq!(0x01020304050607080910111213141516, buf.get_i128());
986+
assert_eq!(0x0102_0304_0506_0708_0910_1112_1314_1516, buf.get_i128());
987987

988988
let mut buf =
989989
&b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01 hello"[..];
990-
assert_eq!(0x01020304050607080910111213141516, buf.get_i128_le());
990+
assert_eq!(0x0102_0304_0506_0708_0910_1112_1314_1516, buf.get_i128_le());
991991

992992
let mut buf = &b"\x01\x02\x03 hello"[..];
993-
assert_eq!(0x010203, buf.get_uint(3));
993+
assert_eq!(0x01_0203, buf.get_uint(3));
994994

995995
let mut buf = &b"\x03\x02\x01 hello"[..];
996-
assert_eq!(0x010203, buf.get_uint_le(3));
996+
assert_eq!(0x01_0203, buf.get_uint_le(3));
997997

998998
let mut buf = &b"\x01\x02\x03 hello"[..];
999-
assert_eq!(0x010203, buf.get_int(3));
999+
assert_eq!(0x01_0203, buf.get_int(3));
10001000

10011001
let mut buf = &b"\x03\x02\x01 hello"[..];
1002-
assert_eq!(0x010203, buf.get_int_le(3));
1002+
assert_eq!(0x01_0203, buf.get_int_le(3));
10031003

10041004
let mut buf = &b"\x3F\x99\x99\x9A hello"[..];
10051005
assert_eq!(1.2f32, buf.get_f32());

0 commit comments

Comments
 (0)