Detecting `std` dependencies in build process of `no_std` target

Hi,

Is there a way of automatically detecting build dependencies that depend on std when building a target that is #![no_std]?

I am building an application that is !#[no_std] and a couple of companion libraries that are also !#[no_std] as well. The test for these libraries however use std for nice logging and debugging.
Somehow I slipped in a pretty_assertions both as a dev and normal dependency of my lib which then caused the compiler to throw lots of errors when building my application.

After some time I was able to find my mistake of having a std dependency in a no_std application but it would have been nice if either the compiler was a bit more helpful with telling me something like: "you are trying to build a no_std application but you depend on std right here: crate_foo_bar-> dependencies: pretty_assertions".

Is there a tool or some cargo or rustc option that helps to detect such a problem?
The compiler is already telling me that it can't find crate std which is great, but usually it is always in the context of some dependency of a dependency that is compiled first, so it is not trivial to see where the std dependency is coming from.

Thanks :pray:

This crate claims to do what you want. GitHub - hobofan/cargo-nono: Check your crate for (possible) no_std compatibility

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.