diff options
author | Benjamin Bouvier <[email protected]> | 2021-02-11 16:34:56 +0000 |
---|---|---|
committer | Benjamin Bouvier <[email protected]> | 2021-02-13 17:20:46 +0000 |
commit | 4a6e602c9419cc5ed464343b2373c7fe86fb89d6 (patch) | |
tree | ed4148a4ccb0a7e81cb897f611e66e40bf492488 /crates/project_model/src/workspace.rs | |
parent | 2967e783ac53e89f06a8f8bd1afc12433311fded (diff) |
Allow automatically detect the rustc-src directory (fixes #3517).
If the configured rustcSource is set to "discover", try to automatically
detect a source from the sysroot rustc directory.
Diffstat (limited to 'crates/project_model/src/workspace.rs')
-rw-r--r-- | crates/project_model/src/workspace.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs index c30861976..0220efdb4 100644 --- a/crates/project_model/src/workspace.rs +++ b/crates/project_model/src/workspace.rs | |||
@@ -114,6 +114,7 @@ impl ProjectWorkspace { | |||
114 | cargo_version | 114 | cargo_version |
115 | ) | 115 | ) |
116 | })?; | 116 | })?; |
117 | |||
117 | let sysroot = if config.no_sysroot { | 118 | let sysroot = if config.no_sysroot { |
118 | Sysroot::default() | 119 | Sysroot::default() |
119 | } else { | 120 | } else { |
@@ -125,7 +126,17 @@ impl ProjectWorkspace { | |||
125 | })? | 126 | })? |
126 | }; | 127 | }; |
127 | 128 | ||
128 | let rustc = if let Some(rustc_dir) = &config.rustc_source { | 129 | let rustc_dir = if let Some(rustc_source) = &config.rustc_source { |
130 | use cargo_workspace::RustcSource; | ||
131 | match rustc_source { | ||
132 | RustcSource::Path(path) => Some(path.clone()), | ||
133 | RustcSource::Discover => Sysroot::discover_rustc(&cargo_toml), | ||
134 | } | ||
135 | } else { | ||
136 | None | ||
137 | }; | ||
138 | |||
139 | let rustc = if let Some(rustc_dir) = rustc_dir { | ||
129 | Some( | 140 | Some( |
130 | CargoWorkspace::from_cargo_metadata(&rustc_dir, config, progress) | 141 | CargoWorkspace::from_cargo_metadata(&rustc_dir, config, progress) |
131 | .with_context(|| { | 142 | .with_context(|| { |