Merge #7464
7464: Export `CARGO` for proc. macros r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/7462 bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
e3204c528b
1 changed files with 4 additions and 1 deletions
|
@ -175,7 +175,7 @@ fn is_dylib(path: &Path) -> bool {
|
|||
/// Should be synced with <https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
|
||||
fn inject_cargo_env(package: &cargo_metadata::Package, env: &mut Vec<(String, String)>) {
|
||||
// FIXME: Missing variables:
|
||||
// CARGO, CARGO_PKG_HOMEPAGE, CARGO_CRATE_NAME, CARGO_BIN_NAME, CARGO_BIN_EXE_<name>
|
||||
// CARGO_PKG_HOMEPAGE, CARGO_CRATE_NAME, CARGO_BIN_NAME, CARGO_BIN_EXE_<name>
|
||||
|
||||
let mut manifest_dir = package.manifest_path.clone();
|
||||
manifest_dir.pop();
|
||||
|
@ -183,6 +183,9 @@ fn inject_cargo_env(package: &cargo_metadata::Package, env: &mut Vec<(String, St
|
|||
env.push(("CARGO_MANIFEST_DIR".into(), cargo_manifest_dir.into()));
|
||||
}
|
||||
|
||||
// Not always right, but works for common cases.
|
||||
env.push(("CARGO".into(), "cargo".into()));
|
||||
|
||||
env.push(("CARGO_PKG_VERSION".into(), package.version.to_string()));
|
||||
env.push(("CARGO_PKG_VERSION_MAJOR".into(), package.version.major.to_string()));
|
||||
env.push(("CARGO_PKG_VERSION_MINOR".into(), package.version.minor.to_string()));
|
||||
|
|
Loading…
Add table
Reference in a new issue