mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
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.
This commit is contained in:
parent
2967e783ac
commit
4a6e602c94
7 changed files with 67 additions and 20 deletions
|
@ -114,6 +114,7 @@ impl ProjectWorkspace {
|
|||
cargo_version
|
||||
)
|
||||
})?;
|
||||
|
||||
let sysroot = if config.no_sysroot {
|
||||
Sysroot::default()
|
||||
} else {
|
||||
|
@ -125,7 +126,17 @@ impl ProjectWorkspace {
|
|||
})?
|
||||
};
|
||||
|
||||
let rustc = if let Some(rustc_dir) = &config.rustc_source {
|
||||
let rustc_dir = if let Some(rustc_source) = &config.rustc_source {
|
||||
use cargo_workspace::RustcSource;
|
||||
match rustc_source {
|
||||
RustcSource::Path(path) => Some(path.clone()),
|
||||
RustcSource::Discover => Sysroot::discover_rustc(&cargo_toml),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let rustc = if let Some(rustc_dir) = rustc_dir {
|
||||
Some(
|
||||
CargoWorkspace::from_cargo_metadata(&rustc_dir, config, progress)
|
||||
.with_context(|| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue