Skip to content

Commit

Permalink
Remove CARGO_RUSTC_CURRENT_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
LHolten committed Dec 31, 2024
1 parent 87c733c commit 431aab1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
14 changes: 2 additions & 12 deletions src/tools/rust-analyzer/crates/project-model/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use paths::Utf8Path;
use rustc_hash::FxHashMap;
use toolchain::Tool;

use crate::{utf8_stdout, CargoWorkspace, ManifestPath, PackageData, Sysroot, TargetKind};
use crate::{utf8_stdout, ManifestPath, PackageData, Sysroot, TargetKind};

/// Recreates the compile-time environment variables that Cargo sets.
///
Expand Down Expand Up @@ -51,23 +51,13 @@ pub(crate) fn inject_cargo_env(env: &mut Env) {
env.set("CARGO", Tool::Cargo.path().to_string());
}

pub(crate) fn inject_rustc_tool_env(
env: &mut Env,
cargo: &CargoWorkspace,
cargo_name: &str,
kind: TargetKind,
) {
pub(crate) fn inject_rustc_tool_env(env: &mut Env, cargo_name: &str, kind: TargetKind) {
_ = kind;
// FIXME
// if kind.is_executable() {
// env.set("CARGO_BIN_NAME", cargo_name);
// }
env.set("CARGO_CRATE_NAME", cargo_name.replace('-', "_"));
// NOTE: Technically we should set this for all crates, but that will worsen the deduplication
// logic so for now just keeping it proc-macros ought to be fine.
if kind.is_proc_macro() {
env.set("CARGO_RUSTC_CURRENT_DIR", cargo.manifest_path().parent().to_string());
}
}

pub(crate) fn cargo_config_env(
Expand Down
6 changes: 2 additions & 4 deletions src/tools/rust-analyzer/crates/project-model/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,12 +1362,10 @@ fn add_target_crate_root(
let mut env = cargo.env().clone();
inject_cargo_package_env(&mut env, pkg);
inject_cargo_env(&mut env);
inject_rustc_tool_env(&mut env, cargo, cargo_name, kind);
inject_rustc_tool_env(&mut env, cargo_name, kind);

if let Some(envs) = build_data.map(|(it, _)| &it.envs) {
for (k, v) in envs {
env.set(k, v.clone());
}
env.extend_from_other(envs);
}
let crate_id = crate_graph.add_crate_root(
file_id,
Expand Down

0 comments on commit 431aab1

Please sign in to comment.