hobofan / cargo-nono

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

False positives when using `extern crate core as std;` #57

Open regexident opened 4 years ago

regexident commented 4 years ago

A fairly common pattern in no_std-compatible projects is to put this in your lib.rs file:

extern crate core as std;

… which allows you to then keep using use std::…, instead of having to use use core::….

Running $ cargo nono check on the lazycell crate, which uses aforementioned trick produces the following errors:

❯ cargo nono check
lazycell: ❌
  - Source code contains an explicit `use std::` statement.
   --> src/lib.rs

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

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

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

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

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

… even though the crate is safe to use for no_std.