Skip to content

Commit 446fef5

Browse files
committed
remove arithmetic_side_effects
part of #4071
1 parent 08c3416 commit 446fef5

14 files changed

Lines changed: 61 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ restriction = { level = "warn", priority = -2 }
113113

114114
# lints to decide on
115115

116-
arithmetic_side_effects = "allow" # TODO: consider
117116
as_conversions = "allow" # TODO: tricky
118117
cast_possible_truncation = "allow" # TODO: consider
119118
cast_precision_loss = "allow" # TODO: consider

src/body/length.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl DecodedLength {
7070
match *self {
7171
DecodedLength::CHUNKED | DecodedLength::CLOSE_DELIMITED => (),
7272
DecodedLength(ref mut known) => {
73-
*known -= amt;
73+
*known = known.saturating_sub(amt);
7474
}
7575
}
7676
}

src/common/buf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl<T: Buf> Buf for BufList<T> {
3838
}
3939

4040
#[inline]
41+
#[allow(clippy::arithmetic_side_effects)]
4142
fn advance(&mut self, mut cnt: usize) {
4243
while cnt > 0 {
4344
{
@@ -56,6 +57,7 @@ impl<T: Buf> Buf for BufList<T> {
5657
}
5758

5859
#[inline]
60+
#[allow(clippy::arithmetic_side_effects)]
5961
fn chunks_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize {
6062
if dst.is_empty() {
6163
return 0;

src/common/date.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ impl CachedDate {
6767
}
6868
}
6969

70+
#[allow(clippy::arithmetic_side_effects)]
7071
fn update(&mut self, now: SystemTime) {
7172
let nanos = now
7273
.duration_since(UNIX_EPOCH)
@@ -95,6 +96,7 @@ impl CachedDate {
9596
}
9697

9798
impl fmt::Write for CachedDate {
99+
#[allow(clippy::arithmetic_side_effects)]
98100
fn write_str(&mut self, s: &str) -> fmt::Result {
99101
let len = s.len();
100102
self.bytes[self.pos..self.pos + len].copy_from_slice(s.as_bytes());

src/common/io/compat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ where
2424
T: crate::rt::Read,
2525
{
2626
/// `poll_read` fn implementation for `Compat<T>`.
27+
#[allow(clippy::arithmetic_side_effects)]
2728
fn poll_read(
2829
self: Pin<&mut Self>,
2930
cx: &mut Context<'_>,

src/ext/h1_reason_phrase.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const fn is_valid_byte(b: u8) -> bool {
157157
b == b'\t' || b == b' ' || is_vchar(b) || is_obs_text(b)
158158
}
159159

160+
#[allow(clippy::arithmetic_side_effects)]
160161
const fn find_invalid_byte(bytes: &[u8]) -> Option<u8> {
161162
let mut i = 0;
162163
while i < bytes.len() {

src/headers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub(super) fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>
6767
content_length
6868
}
6969

70+
#[allow(clippy::arithmetic_side_effects)]
7071
fn from_digits(bytes: &[u8]) -> Option<u64> {
7172
// cannot use FromStr for u64, since it allows a signed prefix
7273
let mut result = 0u64;
@@ -137,6 +138,7 @@ pub(super) fn is_chunked_(value: &HeaderValue) -> bool {
137138
}
138139

139140
#[cfg(all(feature = "client", feature = "http1"))]
141+
#[allow(clippy::arithmetic_side_effects)]
140142
pub(super) fn add_chunked(mut entry: http::header::OccupiedEntry<'_, HeaderValue>) {
141143
const CHUNKED: &str = "chunked";
142144

src/proto/h1/conn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ where
208208
read_buf.len() >= 24 && read_buf[..24] == *H2_PREFACE
209209
}
210210

211+
#[allow(clippy::arithmetic_side_effects)]
211212
pub(super) fn poll_read_head(
212213
&mut self,
213214
cx: &mut Context<'_>,

src/proto/h1/decode.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ impl Decoder {
141141
)
142142
}
143143

144+
#[allow(clippy::arithmetic_side_effects)]
144145
pub(crate) fn decode<R: MemRead>(
145146
&mut self,
146147
cx: &mut Context<'_>,
@@ -339,6 +340,7 @@ impl ChunkedState {
339340
}
340341
}
341342

343+
#[allow(clippy::arithmetic_side_effects)]
342344
fn read_start<R: MemRead>(
343345
cx: &mut Context<'_>,
344346
rdr: &mut R,
@@ -371,6 +373,7 @@ impl ChunkedState {
371373
Poll::Ready(Ok(ChunkedState::Size))
372374
}
373375

376+
#[allow(clippy::arithmetic_side_effects)]
374377
fn read_size<R: MemRead>(
375378
cx: &mut Context<'_>,
376379
rdr: &mut R,
@@ -420,6 +423,7 @@ impl ChunkedState {
420423
))),
421424
}
422425
}
426+
#[allow(clippy::arithmetic_side_effects)]
423427
fn read_extension<R: MemRead>(
424428
cx: &mut Context<'_>,
425429
rdr: &mut R,
@@ -473,6 +477,7 @@ impl ChunkedState {
473477
}
474478
}
475479

480+
#[allow(clippy::arithmetic_side_effects)]
476481
fn read_body<R: MemRead>(
477482
cx: &mut Context<'_>,
478483
rdr: &mut R,
@@ -548,6 +553,7 @@ impl ChunkedState {
548553
}
549554
}
550555

556+
#[allow(clippy::arithmetic_side_effects)]
551557
fn read_trailer_lf<R: MemRead>(
552558
cx: &mut Context<'_>,
553559
rdr: &mut R,

src/proto/h1/encode.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ impl Encoder {
125125
}
126126
}
127127

128+
#[allow(clippy::arithmetic_side_effects)]
128129
pub(crate) fn encode<B>(&mut self, msg: B) -> EncodedBuf<B>
129130
where
130131
B: Buf,
@@ -359,6 +360,7 @@ impl ChunkSize {
359360

360361
impl Buf for ChunkSize {
361362
#[inline]
363+
#[allow(clippy::arithmetic_side_effects)]
362364
fn remaining(&self) -> usize {
363365
(self.len - self.pos).into()
364366
}
@@ -369,6 +371,7 @@ impl Buf for ChunkSize {
369371
}
370372

371373
#[inline]
374+
#[allow(clippy::arithmetic_side_effects)]
372375
fn advance(&mut self, cnt: usize) {
373376
assert!(cnt <= self.remaining());
374377
self.pos += cnt as u8; // just asserted cnt fits in u8
@@ -385,6 +388,7 @@ impl fmt::Debug for ChunkSize {
385388
}
386389

387390
impl fmt::Write for ChunkSize {
391+
#[allow(clippy::arithmetic_side_effects)]
388392
fn write_str(&mut self, num: &str) -> fmt::Result {
389393
use std::io::Write;
390394
(&mut self.bytes[self.len.into()..])

0 commit comments

Comments
 (0)