Why does my non-wasm hyper/rustls project have dependencies `web-sys` in cargo.lock?

Once while compiling, I happened to notice that the crate I was compiling had dependencies like js-sys and web-sys, but my project is not designed for wasm and does not have any related features turned on. However, when I execute cargo tree, I don't find web-sys appearing in the output. After searching in cargo.lock, I found that ring directly depends on web-sys, and after checking ring's Cargo.toml I found that ring only depends on web-sys when opening the non-default feature wasm32_unknown_unknown_js. I just want to ask, does this dependency appear in the final bin compilation product for non-wasm targets?
Dependencies related to hyper/rustls in Cargo.toml:

hyper = { version = "0.14", features = ["http1", "http2", "client", "tcp", "stream"] }
hyper-rustls = { version = "0.23", features = ["webpki-roots"] }

The web-sys dependency of ring is specified to be just for the wasm32-unknown-unknown target and as such will not be compiled for any other target.

I recompiled the bin for the x86_64-pc-windows-msvc target with a cleaned target directory, and the web-sys was indeed not compiled during the process. Probably the cases such as compiling lib are that I saw web-sys being compiled.

Also I would like to ask, will the code and dependencies used to provide the proc macros be present in the final bin compilation product? (I guess the answer maybe is not always, based on what the macro crate author did.)

A proc-macro crate per se is compiled into a sort of compiler plugin: none of its code, including dependencies, can ever end up in the final binary. But the proc macro can generate code that uses any library your crate depends on (including a library that re-exports the proc macro itself, which is a common pattern).

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.