hobofan / cargo-nono

Check your crate for (possible) no_std compatibility
Apache License 2.0
209 stars 12 forks source link

Ignore usage of std in extra binaries #26

Open shepmaster opened 5 years ago

shepmaster commented 5 years ago

I have a little test program paired with my no-std library. cargo nono reports this, although no one but me will ever make use of it:

$ cargo nono check --no-default-features --package twox-hash
twox-hash: ❌
  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Did not find a #![no_std] attribute or a simple conditional attribute like #[cfg_attr(not(feature = "std"), no_std)] in the crate source. Crate most likely doesn't support no_std without changes.
  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

  - Source code contains an explicit `use std::` statement.
   --> src/bin/hash_file.rs

There doesn't appear to be any flags to report on only the library.

hobofan commented 5 years ago

Thanks for the feedback!

Yeah, I don't think we have such a flag at the moment.

Adding a --only-lib flag that causes src/main.rs and src/bin/**/*.rs to be ignored sounds reasonable.