mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
project-model: when using rust-project.json
, prefer the sysroot-defined rustc over an env-based one
This commit is contained in:
parent
f29867bd26
commit
5b5bce8aaf
3 changed files with 41 additions and 12 deletions
|
@ -115,10 +115,19 @@ impl Sysroot {
|
|||
Ok(Sysroot::load(sysroot_dir, src))
|
||||
}
|
||||
|
||||
pub fn discover_rustc(&self) -> Option<ManifestPath> {
|
||||
pub fn discover_rustc_src(&self) -> Option<ManifestPath> {
|
||||
get_rustc_src(&self.root)
|
||||
}
|
||||
|
||||
pub fn discover_rustc(&self) -> Result<AbsPathBuf, std::io::Error> {
|
||||
let rustc = self.root.join("bin/rustc");
|
||||
tracing::debug!(?rustc, "checking for rustc binary at location");
|
||||
match fs::metadata(&rustc) {
|
||||
Ok(_) => Ok(rustc),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_sysroot_dir(sysroot_dir: AbsPathBuf) -> Result<Sysroot> {
|
||||
let sysroot_src_dir = discover_sysroot_src_dir(&sysroot_dir).ok_or_else(|| {
|
||||
format_err!("can't load standard library from sysroot path {sysroot_dir}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue