Skip to content

shuf: lint error legacy_numeric_constants with Rust 1.79.0 #6478

@lcheylus

Description

@lcheylus

When checking lint errors with Rust v1.79.0 (cargo clippy), there are some "usage of a legacy numeric method" errors in src/uu/shuf/src/shuf.rs:

$ cargo clippy --all-targets -puu_shuf -- -W clippy::manual_string_new -D warnings
(...)
    Checking uu_shuf v0.0.26 (/home/fox/dev/Perso/rust-coreutils.git/src/uu/shuf)
error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:534:63
    |
534 |         assert_eq!(false, number_set_should_list_remaining(0, std::usize::MAX));
    |                                                               ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
    = note: `-D clippy::legacy-numeric-constants` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::legacy_numeric_constants)]`
help: use the associated constant instead
    |
534 |         assert_eq!(false, number_set_should_list_remaining(0, usize::MAX));
    |                                                               ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:539:63
    |
539 |         assert_eq!(false, number_set_should_list_remaining(1, std::usize::MAX));
    |                                                               ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
539 |         assert_eq!(false, number_set_should_list_remaining(1, usize::MAX));
    |                                                               ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:544:63
    |
544 |         assert_eq!(false, number_set_should_list_remaining(9, std::usize::MAX));
    |                                                               ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
544 |         assert_eq!(false, number_set_should_list_remaining(9, usize::MAX));
    |                                                               ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:590:53
    |
590 |             number_set_should_list_remaining(12345, std::usize::MAX)
    |                                                     ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
590 |             number_set_should_list_remaining(12345, usize::MAX)
    |                                                     ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:598:46
    |
598 |             number_set_should_list_remaining(std::usize::MAX - 1, std::usize::MAX)
    |                                              ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
598 |             number_set_should_list_remaining(usize::MAX - 1, std::usize::MAX)
    |                                              ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:598:67
    |
598 |             number_set_should_list_remaining(std::usize::MAX - 1, std::usize::MAX)
    |                                                                   ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
598 |             number_set_should_list_remaining(std::usize::MAX - 1, usize::MAX)
    |                                                                   ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:606:46
    |
606 |             number_set_should_list_remaining(std::usize::MAX, std::usize::MAX)
    |                                              ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
606 |             number_set_should_list_remaining(usize::MAX, std::usize::MAX)
    |                                              ~~~~~~~~~~

error: usage of a legacy numeric constant
   --> src/uu/shuf/src/shuf.rs:606:63
    |
606 |             number_set_should_list_remaining(std::usize::MAX, std::usize::MAX)
    |                                                               ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants
help: use the associated constant instead
    |
606 |             number_set_should_list_remaining(std::usize::MAX, usize::MAX)
    |                                                               ~~~~~~~~~~

error: could not compile `uu_shuf` (lib test) due to 8 previous errors

std::usize::MAX needs to be replaced by usize::MAX => deprecated in future version, see https://rust-lang.github.io/rust-clippy/master/index.html#/legacy_numeric_constants

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions