about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/rust-analyzer/crates/ide-completion/src/completions/env_vars.rs1
-rw-r--r--src/tools/rust-analyzer/crates/project-model/src/env.rs1
-rw-r--r--src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt5
-rw-r--r--src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt5
-rw-r--r--src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt5
5 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/completions/env_vars.rs b/src/tools/rust-analyzer/crates/ide-completion/src/completions/env_vars.rs
index cd18b3dcfdc..92cbf411c1e 100644
--- a/src/tools/rust-analyzer/crates/ide-completion/src/completions/env_vars.rs
+++ b/src/tools/rust-analyzer/crates/ide-completion/src/completions/env_vars.rs
@@ -13,6 +13,7 @@ use crate::{
 const CARGO_DEFINED_VARS: &[(&str, &str)] = &[
     ("CARGO", "Path to the cargo binary performing the build"),
     ("CARGO_MANIFEST_DIR", "The directory containing the manifest of your package"),
+    ("CARGO_MANIFEST_PATH", "The path to the manifest of your package"),
     ("CARGO_PKG_VERSION", "The full version of your package"),
     ("CARGO_PKG_VERSION_MAJOR", "The major version of your package"),
     ("CARGO_PKG_VERSION_MINOR", "The minor version of your package"),
diff --git a/src/tools/rust-analyzer/crates/project-model/src/env.rs b/src/tools/rust-analyzer/crates/project-model/src/env.rs
index e7293b0b2ef..450def5461d 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/env.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/env.rs
@@ -18,6 +18,7 @@ pub(crate) fn inject_cargo_package_env(env: &mut Env, package: &PackageData) {
 
     let manifest_dir = package.manifest.parent();
     env.set("CARGO_MANIFEST_DIR", manifest_dir.as_str());
+    env.set("CARGO_MANIFEST_PATH", package.manifest.as_str());
 
     env.set("CARGO_PKG_VERSION", package.version.to_string());
     env.set("CARGO_PKG_VERSION_MAJOR", package.version.major.to_string());
diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt
index 4ef9d816119..3722e2c7216 100644
--- a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt
+++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model.txt
@@ -52,6 +52,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "hello_world",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -136,6 +137,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "hello_world",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -220,6 +222,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "an_example",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -304,6 +307,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "it",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -384,6 +388,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "libc",
                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
+                "CARGO_MANIFEST_PATH": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "The Rust Project Developers",
                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n",
                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc",
diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt
index 4ef9d816119..3722e2c7216 100644
--- a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt
+++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt
@@ -52,6 +52,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "hello_world",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -136,6 +137,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "hello_world",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -220,6 +222,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "an_example",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -304,6 +307,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "it",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -384,6 +388,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "libc",
                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
+                "CARGO_MANIFEST_PATH": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "The Rust Project Developers",
                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n",
                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc",
diff --git a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt
index 52089d1dbc2..7b156ea63a5 100644
--- a/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt
+++ b/src/tools/rust-analyzer/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt
@@ -51,6 +51,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "hello_world",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -134,6 +135,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "hello_world",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -217,6 +219,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "an_example",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -300,6 +303,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "it",
                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world",
+                "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "",
                 "CARGO_PKG_DESCRIPTION": "",
                 "CARGO_PKG_HOMEPAGE": "",
@@ -380,6 +384,7 @@
                 "CARGO": "$CARGO$",
                 "CARGO_CRATE_NAME": "libc",
                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
+                "CARGO_MANIFEST_PATH": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/Cargo.toml",
                 "CARGO_PKG_AUTHORS": "The Rust Project Developers",
                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n",
                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc",