diff options
author | Aleksey Kladov <[email protected]> | 2020-11-06 10:29:54 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-11-06 10:30:57 +0000 |
commit | 85db47ac76c383295caee0c1d4284544b761add9 (patch) | |
tree | f7484f09c6b8c56ffcc996bf01bad6ce167bc904 /crates/project_model/src | |
parent | 7709b6a2d4b74b5838fbe5b30b6188d6a549b580 (diff) |
Ignore RUST_SRC_PATH if it is set to invalid value
Folks report a ton of hard-to-diagnose issues, the solution for which
is "unset RUST_SRC_PATH". Let's just ignore RUST_SRC_PATH when it
won't work anyway!
Diffstat (limited to 'crates/project_model/src')
-rw-r--r-- | crates/project_model/src/sysroot.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/project_model/src/sysroot.rs b/crates/project_model/src/sysroot.rs index 3fe494729..b0e8863f6 100644 --- a/crates/project_model/src/sysroot.rs +++ b/crates/project_model/src/sysroot.rs | |||
@@ -114,8 +114,12 @@ fn discover_sysroot_src_dir(current_dir: &AbsPath) -> Result<AbsPathBuf> { | |||
114 | if let Ok(path) = env::var("RUST_SRC_PATH") { | 114 | if let Ok(path) = env::var("RUST_SRC_PATH") { |
115 | let path = AbsPathBuf::try_from(path.as_str()) | 115 | let path = AbsPathBuf::try_from(path.as_str()) |
116 | .map_err(|path| format_err!("RUST_SRC_PATH must be absolute: {}", path.display()))?; | 116 | .map_err(|path| format_err!("RUST_SRC_PATH must be absolute: {}", path.display()))?; |
117 | log::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display()); | 117 | let core = path.join("core"); |
118 | return Ok(path); | 118 | if core.exists() { |
119 | log::debug!("Discovered sysroot by RUST_SRC_PATH: {}", path.display()); | ||
120 | return Ok(path); | ||
121 | } | ||
122 | log::debug!("RUST_SRC_PATH is set, but is invalid (no core: {:?}), ignoring", core); | ||
119 | } | 123 | } |
120 | 124 | ||
121 | let sysroot_path = { | 125 | let sysroot_path = { |