Skip to content

Commit

Permalink
style: Remove use of legacy numeric constants (#1089)
Browse files Browse the repository at this point in the history
Cargo clippy reports:

```
warning: usage of a legacy numeric method
  --> prost/src/lib.rs:71:24
   |
71 |     if length > usize::max_value() as u64 {
   |                        ^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
   |
71 |     if length > usize::MAX as u64 {
   |                        ~~~
```
  • Loading branch information
caspermeijn authored Jul 12, 2024
1 parent 688da45 commit ee61946
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
PROTOC_VERSION: 3.20.3
clippy_rust_version: 1.78
clippy_rust_version: 1.79

jobs:
# Depends on all actions that are required for a "successful" CI run.
Expand Down
2 changes: 0 additions & 2 deletions prost-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ mod protobuf;

use core::convert::TryFrom;
use core::fmt;
use core::i32;
use core::i64;
use core::str::FromStr;
use core::time;

Expand Down
3 changes: 0 additions & 3 deletions prost/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use alloc::vec::Vec;
use core::cmp::min;
use core::mem;
use core::str;
use core::u32;
use core::usize;

use ::bytes::{Buf, BufMut, Bytes};

Expand Down Expand Up @@ -1350,7 +1348,6 @@ mod test {
use alloc::string::ToString;
use core::borrow::Borrow;
use core::fmt::Debug;
use core::u64;

use ::bytes::BytesMut;
use proptest::{prelude::*, test_runner::TestCaseResult};
Expand Down
2 changes: 1 addition & 1 deletion prost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn length_delimiter_len(length: usize) -> usize {
/// delimiter, and typically the buffer should be considered corrupt.
pub fn decode_length_delimiter(mut buf: impl Buf) -> Result<usize, DecodeError> {
let length = decode_varint(&mut buf)?;
if length > usize::max_value() as u64 {
if length > usize::MAX as u64 {
return Err(DecodeError::new(
"length delimiter exceeds maximum usize value",
));
Expand Down

0 comments on commit ee61946

Please sign in to comment.