8624: Automatically detect rust library source file map  r=vsrs a=vsrs

This PR adds a new possible `rust-analyzer.debug.sourceFileMap` value:
```json
{
    "rust-analyzer.debug.sourceFileMap": "auto"
}
```

I did not make it the default because it uses two shell calls (`rustc --print sysroot` and `rustc -V -v`). First one can be slow (https://github.com/rust-lang/rustup/issues/783)

Fixes #8619

Co-authored-by: vsrs <vit@conrlab.com>
This commit is contained in:
bors[bot] 2021-04-27 20:41:35 +00:00 committed by GitHub
commit fb45d2adec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 8 deletions

View file

@ -135,8 +135,12 @@ export class Config {
}
get debug() {
// "/rustc/<id>" used by suggestions only.
const { ["/rustc/<id>"]: _, ...sourceFileMap } = this.get<Record<string, string>>("debug.sourceFileMap");
let sourceFileMap = this.get<Record<string, string> | "auto">("debug.sourceFileMap");
if (sourceFileMap !== "auto") {
// "/rustc/<id>" used by suggestions only.
const { ["/rustc/<id>"]: _, ...trimmed } = this.get<Record<string, string>>("debug.sourceFileMap");
sourceFileMap = trimmed;
}
return {
engine: this.get<string>("debug.engine"),