diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index bed881d50db1..ac8b17680b29 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -696,16 +696,14 @@ fn prepare_rustc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResult let tmp = build_runner.files().layout(unit.kind).prepare_tmp()?; base.env("CARGO_TARGET_TMPDIR", tmp.display().to_string()); } - if build_runner.bcx.gctx.nightly_features_allowed { - // This must come after `build_base_args` (which calls `add_path_args`) so that the `cwd` - // is set correctly. - base.env( - "CARGO_RUSTC_CURRENT_DIR", - base.get_cwd() - .map(|c| c.display().to_string()) - .unwrap_or(String::new()), - ); - } + // This must come after `build_base_args` (which calls `add_path_args`) so that the `cwd` + // is set correctly. + base.env( + "CARGO_RUSTC_CURRENT_DIR", + base.get_cwd() + .map(|c| c.display().to_string()) + .unwrap_or(String::new()), + ); Ok(base) } diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index 40a0d32f1ae5..a00399ddfe52 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -265,7 +265,7 @@ corresponding environment variable is set to the empty string, `""`. where integration tests or benchmarks are free to put any data needed by the tests/benches. Cargo initially creates this directory but doesn't manage its content in any way, this is the responsibility of the test code. -* `CARGO_RUSTC_CURRENT_DIR` --- This is a path that `rustc` is invoked from **(nightly only)**. +* `CARGO_RUSTC_CURRENT_DIR` --- This is a path that `rustc` is invoked from [Cargo target]: cargo-targets.md [binaries]: cargo-targets.md#binaries diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 17965aa8dcf9..f1addda28aeb 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1705,9 +1705,7 @@ fn crate_env_vars() { }; println!("build"); - p.cargo("build -v") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .run(); + p.cargo("build -v").run(); println!("bin"); p.process(&p.bin("foo-bar")) @@ -1715,20 +1713,14 @@ fn crate_env_vars() { .run(); println!("example"); - p.cargo("run --example ex-env-vars -v") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .run(); + p.cargo("run --example ex-env-vars -v").run(); println!("test"); - p.cargo("test -v") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .run(); + p.cargo("test -v").run(); if is_nightly() { println!("bench"); - p.cargo("bench -v") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) - .run(); + p.cargo("bench -v").run(); } } @@ -1814,11 +1806,9 @@ fn cargo_rustc_current_dir_foreign_workspace_dep() { // Verify it works from a different workspace foo.cargo("test -p baz") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) .with_stdout_contains("running 1 test\ntest baz_env ... ok") .run(); foo.cargo("test -p baz_member") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) .with_stdout_contains("running 1 test\ntest baz_member_env ... ok") .run(); } @@ -1863,33 +1853,10 @@ fn cargo_rustc_current_dir_non_local_dep() { .build(); p.cargo("test -p bar") - .masquerade_as_nightly_cargo(&["CARGO_RUSTC_CURRENT_DIR"]) .with_stdout_contains("running 1 test\ntest bar_env ... ok") .run(); } -#[cargo_test] -fn cargo_rustc_current_dir_is_not_stable() { - if is_nightly() { - return; - } - let p = project() - .file( - "tests/env.rs", - r#" - use std::path::Path; - - #[test] - fn env() { - assert_eq!(option_env!("CARGO_RUSTC_CURRENT_DIR"), None); - } - "#, - ) - .build(); - - p.cargo("test").run(); -} - #[cargo_test] fn crate_authors_env_vars() { let p = project()