eminence / procfs

Rust library for reading the Linux procfs filesystem
Other
367 stars 106 forks source link

fix all warnings and some clippy lints #160

Closed pymongo closed 2 years ago

pymongo commented 2 years ago

I spent a lot of time to fix all rustc/clippy warnings, please take a look, thanks

pymongo commented 2 years ago

I fix all clippy lints exclude this

[w@ww procfs]$ cargo clippy
warning: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
 --> src/lib.rs:3:10
  |
3 | #![allow(clippy::unknown_clippy_lints)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints`
  |
  = note: `#[warn(renamed_and_removed_lints)]` on by default

warning: `procfs` (lib) generated 1 warning
eminence commented 2 years ago

Hi, thanks for the fixes.

Can you please also test with rust 1.34 and rust 1.42? Some of the changes are not compatible with these older versions of rust, for example:

error[E0658]: use of unstable library feature 'range_contains': recently added as per RFC (see issue #32311)
   --> src/pressure.rs:158:23
    |
158 |         (0.00..100.0).contains(&value)
    |                       ^^^^^^^^

error: aborting due to previous error
pymongo commented 2 years ago

sorry, both 1.34 and 1.42 could not compile on my computer due to other dependencies, so I could only wait CI to check 1.34 and 1.42 compile

[w@ww procfs]$ cargo +1.34 check
    Updating crates.io index
  Downloaded hex v0.4.3
  Downloaded byteorder v1.4.3
  Downloaded chrono v0.4.19
  Downloaded lazy_static v1.4.0
  Downloaded bitflags v1.3.2
  Downloaded flate2 v1.0.22
  Downloaded libc v0.2.107
  Downloaded num-traits v0.2.14
  Downloaded num-integer v0.1.44
  Downloaded time v0.1.44
  Downloaded crc32fast v1.2.1
  Downloaded cfg-if v1.0.0
   Compiling autocfg v1.0.1
   Compiling libc v0.2.107
   Compiling crc32fast v1.2.1
    Checking cfg-if v1.0.0
    Checking adler v1.0.2
    Checking byteorder v1.4.3
    Checking hex v0.4.3
    Checking lazy_static v1.4.0
    Checking bitflags v1.3.2
error[E0658]: use of unstable library feature 'alloc': this library is unlikely to be stabilized in its current form or name (see issue #27783)
  --> /home/w/.cargo/registry/src/github.com-1ecc6299db9ec823/hex-0.4.3/src/lib.rs:41:1
   |
41 | extern crate alloc;
   | ^^^^^^^^^^^^^^^^^^^

   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling miniz_oxide v0.4.4
error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: Could not compile `hex`.
warning: build failed, waiting for other jobs to finish...
error: build failed
[w@ww procfs]$ cargo clean && rm Cargo.lock 
[w@ww procfs]$ cargo +1.42 check
    Updating `https://rsproxy.cn/crates.io-index` index
   Compiling autocfg v1.0.1
   Compiling libc v0.2.107
   Compiling crc32fast v1.2.1
    Checking adler v1.0.2
    Checking cfg-if v1.0.0
    Checking bitflags v1.3.2
    Checking byteorder v1.4.3
    Checking lazy_static v1.4.0
    Checking hex v0.4.3
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling miniz_oxide v0.4.4
    Checking time v0.1.44
    Checking flate2 v1.0.22
    Checking chrono v0.4.19
    Checking procfs v0.11.0 (/home/w/repos/fork_repos/procfs)
error[E0658]: `if` is not allowed in a `const fn`
   --> src/process/mod.rs:103:1
    |
103 | / bitflags! {
104 | |     /// Kernel flags for a process
105 | |     ///
106 | |     /// See also the [Stat::flags()] method.
...   |
171 | |     }
172 | | }
    | |_^
eminence commented 2 years ago

Check the README for more info, but if you want to test with 1.34, you have to manually pin some of the dependencies to older versions that will work with 1.34:

cargo update -p hex --precise 0.4.2
cargo update -p bitflags --precise 1.2.1
cargo update -p flate2 --precise 1.0.21
pymongo commented 2 years ago

seems my code is pass 1.34 and 1.42 rustc compile in CI, any other problem need I to solve?

eminence commented 2 years ago

Thanks! I'll take a look in a few days

eminence commented 2 years ago

Thanks!