bazelbuild / bazelbuild/rules_rust

Stop using 0.0.0 as a fallback version for rustc compilation.

Open
#3,674 1 comment 0 reactions 0 assignees View on GitHub
awaiting-response
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

If the `version` attribute is omitted, we set rustc env vars corresponding to an assumed version of 0.0.0 (such as `CARGO_PKG_VERSION_MAJOR=0`, etc.). We only set these for rustc compilation, but we omit them for running the cargo build script itself, which is inconsistent with the behavior when version _is_ provided (in which case, the env vars are set both for compilation and build script execution). In addition, these env vars can conflict with the `.env` files that are provided to the `rustc_env_files` and `build_script_env_files` attributes, in which case their values are overridden by the values in the files.

To resolve the inconsistencies and make it easier to reason about the behavior, if the `version` attribute is omitted, we will stop injecting the "0.0.0" version and skip setting the extra env vars, as long as the `incompatible_do_not_inject_degenerate_version_to_rustc_env` flag is enabled.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.