diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 18aeba091..aed838bb0 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -256,14 +256,6 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { cmd.env_remove("RUSTC_WRAPPER"); } cmd.env("RUSTFLAGS", bcx.rustflags_args(unit).join(" ")); - let version = crate::version(); - cmd.env( - "CARGO_VERSION", - format!("{}.{}.{}", version.major, version.minor, version.patch), - ); - cmd.env("CARGO_VERSION_MAJOR", version.major.to_string()); - cmd.env("CARGO_VERSION_MINOR", version.minor.to_string()); - cmd.env("CARGO_VERSION_PATCH", version.patch.to_string()); let version = &bcx.rustc().version; cmd.env( "RUSTC_VERSION", diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index 834b59c9d..373612db2 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -344,9 +344,6 @@ let out_dir = env::var("OUT_DIR").unwrap(); * `RUSTFLAGS` — the `RUSTFLAGS` that Cargo invokes `rustc` with. See [`build.rustflags`]. * `CARGO_PKG_` - The package information variables, with the same names and values as are [provided during crate building][variables set for crates]. -* `CARGO_VERSION` - The version of cargo used to invoke the build - script. Its constituent parts are also available as - `CARGO_VERSION_MAJOR`, `_MINOR`, and `_PATCH`. * `RUSTC_VERSION` - The version of rustc used by the cargo that invokes the build script. Its constituent parts are also available as `CARGO_VERSION_MAJOR`, `_MINOR`, and diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 452ca7c52..52c246a47 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -82,7 +82,6 @@ fn custom_build_env_vars() { ) .file("bar/src/lib.rs", "pub fn hello() {}"); - let cargo_version = cargo::version(); let rustc_version = semver::Version::parse(rustc_release()).unwrap(); let file_content = format!( r#" @@ -126,23 +125,14 @@ fn custom_build_env_vars() { let rustflags = env::var("RUSTFLAGS").unwrap(); assert_eq!(rustflags, ""); - let version = env::var("CARGO_VERSION").unwrap(); - assert_eq!(version, "{1}.{2}.{3}", "bad cargo version"); - let version = env::var("CARGO_VERSION_MAJOR").unwrap(); - assert_eq!(version, "{1}"); - let version = env::var("CARGO_VERSION_MINOR").unwrap(); - assert_eq!(version, "{2}"); - let version = env::var("CARGO_VERSION_PATCH").unwrap(); - assert_eq!(version, "{3}"); - let version = env::var("RUSTC_VERSION").unwrap(); - assert_eq!(version, "{4}.{5}.{6}", "bad rust version"); + assert_eq!(version, "{1}.{2}.{3}", "bad rust version"); let version = env::var("RUSTC_VERSION_MAJOR").unwrap(); - assert_eq!(version, "{4}"); + assert_eq!(version, "{1}"); let version = env::var("RUSTC_VERSION_MINOR").unwrap(); - assert_eq!(version, "{5}"); + assert_eq!(version, "{2}"); let version = env::var("RUSTC_VERSION_PATCH").unwrap(); - assert_eq!(version, "{6}"); + assert_eq!(version, "{3}"); }} "#, p.root() @@ -150,9 +140,6 @@ fn custom_build_env_vars() { .join("debug") .join("build") .display(), - cargo_version.major, - cargo_version.minor, - cargo_version.patch, rustc_version.major, rustc_version.minor, rustc_version.patch,