Skip to content

Commit 35b67e8

Browse files
authored
style(lib): removing cast_lossless lint (#4087)
1 parent e3bcd37 commit 35b67e8

5 files changed

Lines changed: 9 additions & 10 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ restriction = { level = "warn", priority = -2 }
116116
arithmetic_side_effects = "allow" # TODO: consider
117117
as_conversions = "allow" # TODO: tricky
118118
borrow_as_ptr = "allow"
119-
cast_lossless = "allow" # TODO: easy fix
120119
cast_possible_truncation = "allow" # TODO: consider
121120
cast_precision_loss = "allow" # TODO: consider
122121
checked_conversions = "allow"

src/common/date.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl CachedDate {
7474
.subsec_nanos();
7575

7676
self.render(now);
77-
self.next_update = now + Duration::new(1, 0) - Duration::from_nanos(nanos as u64);
77+
self.next_update = now + Duration::new(1, 0) - Duration::from_nanos(u64::from(nanos));
7878
}
7979

8080
fn render(&mut self, now: SystemTime) {

src/headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn from_digits(bytes: &[u8]) -> Option<u64> {
8484
match b {
8585
b'0'..=b'9' => {
8686
result = result.checked_mul(RADIX)?;
87-
result = result.checked_add((b - b'0') as u64)?;
87+
result = result.checked_add(u64::from(b - b'0'))?;
8888
}
8989
_ => {
9090
// not a DIGIT, get outta here!

src/proto/h1/decode.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,15 @@ impl ChunkedState {
357357
match byte!(rdr, cx) {
358358
b @ b'0'..=b'9' => {
359359
*size = or_overflow!(size.checked_mul(radix));
360-
*size = or_overflow!(size.checked_add((b - b'0') as u64));
360+
*size = or_overflow!(size.checked_add(u64::from(b - b'0')));
361361
}
362362
b @ b'a'..=b'f' => {
363363
*size = or_overflow!(size.checked_mul(radix));
364-
*size = or_overflow!(size.checked_add((b + 10 - b'a') as u64));
364+
*size = or_overflow!(size.checked_add(u64::from(b + 10 - b'a')));
365365
}
366366
b @ b'A'..=b'F' => {
367367
*size = or_overflow!(size.checked_mul(radix));
368-
*size = or_overflow!(size.checked_add((b + 10 - b'A') as u64));
368+
*size = or_overflow!(size.checked_add(u64::from(b + 10 - b'A')));
369369
}
370370
_ => {
371371
return Poll::Ready(Err(io::Error::new(
@@ -389,15 +389,15 @@ impl ChunkedState {
389389
match byte!(rdr, cx) {
390390
b @ b'0'..=b'9' => {
391391
*size = or_overflow!(size.checked_mul(radix));
392-
*size = or_overflow!(size.checked_add((b - b'0') as u64));
392+
*size = or_overflow!(size.checked_add(u64::from(b - b'0')));
393393
}
394394
b @ b'a'..=b'f' => {
395395
*size = or_overflow!(size.checked_mul(radix));
396-
*size = or_overflow!(size.checked_add((b + 10 - b'a') as u64));
396+
*size = or_overflow!(size.checked_add(u64::from(b + 10 - b'a')));
397397
}
398398
b @ b'A'..=b'F' => {
399399
*size = or_overflow!(size.checked_mul(radix));
400-
*size = or_overflow!(size.checked_add((b + 10 - b'A') as u64));
400+
*size = or_overflow!(size.checked_add(u64::from(b + 10 - b'A')));
401401
}
402402
b'\t' | b' ' => return Poll::Ready(Ok(ChunkedState::SizeLws)),
403403
b';' => return Poll::Ready(Ok(ChunkedState::Extension)),

src/proto/h2/ping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl Bdp {
423423
fn seconds(dur: Duration) -> f64 {
424424
const NANOS_PER_SEC: f64 = 1_000_000_000.0;
425425
let secs = dur.as_secs() as f64;
426-
secs + (dur.subsec_nanos() as f64) / NANOS_PER_SEC
426+
secs + (f64::from(dur.subsec_nanos())) / NANOS_PER_SEC
427427
}
428428

429429
// ===== impl KeepAlive =====

0 commit comments

Comments
 (0)