mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Autodetect rust library source file map
This commit is contained in:
parent
d1c9bd134d
commit
8f781e782c
2 changed files with 31 additions and 2 deletions
|
@ -121,6 +121,27 @@ export class Cargo {
|
|||
}
|
||||
}
|
||||
|
||||
/** Mirrors `project_model::sysroot::discover_sysroot_dir()` implementation*/
|
||||
export function sysrootForDir(dir: string): Promise<string> {
|
||||
const rustc_path = getPathForExecutable("rustc");
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
cp.exec(`${rustc_path} --print sysroot`, { cwd: dir }, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
reject(new Error(stderr));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(stdout.trimEnd());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Mirrors `toolchain::cargo()` implementation */
|
||||
export function cargoPath(): string {
|
||||
return getPathForExecutable("cargo");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue