setup-rust-toolchain
setup-rust-toolchain copied to clipboard
Why set CARGO_PROFILE_DEV_DEBUG=0?
This actions sets CARGO_PROFILE_DEV_DEBUG to 0, disabling debug info, thereby removing line numbers from backtraces. I wanted to ask about the reasoning for this, since line numbers are useful. Does this make the cache too big?
The setting of CARGO_PROFILE_DEV_DEBUG comes from this blog post: https://matklad.github.io/2021/09/04/fast-rust-builds.html#CI-Workflow
Disable debuginfo — it makes ./target much bigger, which again harms caching. Depending on your preferred workflow, you might consider disabling debuginfo unconditionally, this brings some benefits for local builds as well.
Some other settings are also due to this blog post. dtolnay/rust-toolchain is another source for some settings.
For the debug information, it appears that nowadays rust-analyzer uses the value 1, i.e., "limited" instead of fully disabling it.
What I think might be a good compromise is to have more debugging information for the current crate, i.e., the one being tested, and reduce the debug information for dependencies. Cargo supports that https://doc.rust-lang.org/cargo/reference/profiles.html#overrides but it is not exposed via environment variables.
The "line-tables-only" option was only introduced later to rust, but might otherwise also be a good option.