As cargo check
shows, it's often useful to check if your program is well-formed without actually generating code (an often pretty time-consuming task). I want to check a single (library) Rust file with rustc
directly (I cannot use Cargo!).
cargo check
apparently works by calling this:
rustc --emit=metadata -Z no-codegen
This only emits metadata, a .rmeta
file. Cargo actually needs that to check crates dependent on the checked crate. In my case I really don't need the metadata file.
I tried the following:
rustc --crate-type=lib --emit=
rustc --crate-type=lib --emit=nothing
But both didn't work. I use --crate-type=lib
because my file doesn't have a main
function. I need a platform-independent solution (I don't just want to use it on my machine, but use it in a public script).
How do I make rustc
not write a single file?