summaryrefslogtreecommitdiff
path: root/src/project.rs
diff options
context:
space:
mode:
authorEmmanuel Roullit <eroullit@github.com>2023-02-25 17:11:43 +0100
committerGitHub <noreply@github.com>2023-02-25 17:11:43 +0100
commitfcadbfc70d578e4a993711d5a7f1737aebd6b3ce (patch)
tree897142c1904755a43aefce56695c0b8186381e69 /src/project.rs
parentb653d4848a52701d2240f130ab74c158dd5d7069 (diff)
parent701b4bef51b50d1fd3bb7fbfe3cc274f2bbdcb0c (diff)
Merge branch 'rust-lang:main' into codespaces
Diffstat (limited to 'src/project.rs')
-rw-r--r--src/project.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/project.rs b/src/project.rs
index 0df00b9..6e48350 100644
--- a/src/project.rs
+++ b/src/project.rs
@@ -1,5 +1,6 @@
use glob::glob;
use serde::{Deserialize, Serialize};
+use std::env;
use std::error::Error;
use std::process::Command;
@@ -54,7 +55,7 @@ impl RustAnalyzerProject {
/// Parse the exercises folder for .rs files, any matches will create
/// a new `crate` in rust-project.json which allows rust-analyzer to
/// treat it like a normal binary
- pub fn exercies_to_json(&mut self) -> Result<(), Box<dyn Error>> {
+ pub fn exercises_to_json(&mut self) -> Result<(), Box<dyn Error>> {
for e in glob("./exercises/**/*")? {
let path = e?.to_string_lossy().to_string();
self.path_to_json(path);
@@ -64,6 +65,12 @@ impl RustAnalyzerProject {
/// Use `rustc` to determine the default toolchain
pub fn get_sysroot_src(&mut self) -> Result<(), Box<dyn Error>> {
+ // check if RUST_SRC_PATH is set
+ if let Ok(path) = env::var("RUST_SRC_PATH") {
+ self.sysroot_src = path;
+ return Ok(());
+ }
+
let toolchain = Command::new("rustc")
.arg("--print")
.arg("sysroot")