Skip to content

Commit c16b9d4

Browse files
author
Jon Gjengset
committed
Remove CARGO_VERSION* env vars
Cargo and Rustc are co-versioned at the moment anyway.
1 parent 715fab4 commit c16b9d4

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

src/cargo/core/compiler/custom_build.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,6 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
256256
cmd.env_remove("RUSTC_WRAPPER");
257257
}
258258
cmd.env("RUSTFLAGS", bcx.rustflags_args(unit).join(" "));
259-
let version = crate::version();
260-
cmd.env(
261-
"CARGO_VERSION",
262-
format!("{}.{}.{}", version.major, version.minor, version.patch),
263-
);
264-
cmd.env("CARGO_VERSION_MAJOR", version.major.to_string());
265-
cmd.env("CARGO_VERSION_MINOR", version.minor.to_string());
266-
cmd.env("CARGO_VERSION_PATCH", version.patch.to_string());
267259
let version = &bcx.rustc().version;
268260
cmd.env(
269261
"RUSTC_VERSION",

src/doc/src/reference/environment-variables.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,6 @@ let out_dir = env::var("OUT_DIR").unwrap();
344344
* `RUSTFLAGS` — the `RUSTFLAGS` that Cargo invokes `rustc` with.
345345
See [`build.rustflags`].
346346
* `CARGO_PKG_<var>` - The package information variables, with the same names and values as are [provided during crate building][variables set for crates].
347-
* `CARGO_VERSION` - The version of cargo used to invoke the build
348-
script. Its constituent parts are also available as
349-
`CARGO_VERSION_MAJOR`, `_MINOR`, and `_PATCH`.
350347
* `RUSTC_VERSION` - The version of rustc used by the cargo that invokes
351348
the build script. Its constituent parts are also
352349
available as `CARGO_VERSION_MAJOR`, `_MINOR`, and

tests/testsuite/build_script.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ fn custom_build_env_vars() {
8282
)
8383
.file("bar/src/lib.rs", "pub fn hello() {}");
8484

85-
let cargo_version = cargo::version();
8685
let rustc_version = semver::Version::parse(rustc_release()).unwrap();
8786
let file_content = format!(
8887
r#"
@@ -126,33 +125,21 @@ fn custom_build_env_vars() {
126125
let rustflags = env::var("RUSTFLAGS").unwrap();
127126
assert_eq!(rustflags, "");
128127
129-
let version = env::var("CARGO_VERSION").unwrap();
130-
assert_eq!(version, "{1}.{2}.{3}", "bad cargo version");
131-
let version = env::var("CARGO_VERSION_MAJOR").unwrap();
132-
assert_eq!(version, "{1}");
133-
let version = env::var("CARGO_VERSION_MINOR").unwrap();
134-
assert_eq!(version, "{2}");
135-
let version = env::var("CARGO_VERSION_PATCH").unwrap();
136-
assert_eq!(version, "{3}");
137-
138128
let version = env::var("RUSTC_VERSION").unwrap();
139-
assert_eq!(version, "{4}.{5}.{6}", "bad rust version");
129+
assert_eq!(version, "{1}.{2}.{3}", "bad rust version");
140130
let version = env::var("RUSTC_VERSION_MAJOR").unwrap();
141-
assert_eq!(version, "{4}");
131+
assert_eq!(version, "{1}");
142132
let version = env::var("RUSTC_VERSION_MINOR").unwrap();
143-
assert_eq!(version, "{5}");
133+
assert_eq!(version, "{2}");
144134
let version = env::var("RUSTC_VERSION_PATCH").unwrap();
145-
assert_eq!(version, "{6}");
135+
assert_eq!(version, "{3}");
146136
}}
147137
"#,
148138
p.root()
149139
.join("target")
150140
.join("debug")
151141
.join("build")
152142
.display(),
153-
cargo_version.major,
154-
cargo_version.minor,
155-
cargo_version.patch,
156143
rustc_version.major,
157144
rustc_version.minor,
158145
rustc_version.patch,

0 commit comments

Comments
 (0)