Skip to content

feat: Automatically detect rust library source file map - #8624

Merged
bors[bot] merged 3 commits into
rust-lang:masterfrom
vsrs:auto_src_map
Apr 27, 2021
Merged

bors[bot] merged 3 commits into
rust-lang:masterfrom
vsrs:auto_src_map

Conversation

@vsrs

@vsrs vsrs commented Apr 22, 2021

Copy link
Copy Markdown
Contributor

This PR adds a new possible rust-analyzer.debug.sourceFileMap value:

{
    "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 (rust-lang/rustup#783)

Fixes #8619

@EFanZh

EFanZh commented Apr 23, 2021 •

Copy link
Copy Markdown

I also found that there are paths start with /cargo/, Like /cargo/registry/src/hub.lumenfield.work-1ecc6299db9ec823/. Is it a good idea to map it to the user .cargo cache? Like ~/.cargo/?

Also, the "auto" value prevents user from adding custom source mappings. How about using a separate configuration property for this?

@vsrs

vsrs commented Apr 23, 2021

Copy link
Copy Markdown
Contributor Author

I also found that there are paths start with /cargo/, Like /cargo/registry/src/hub.lumenfield.work-1ecc6299db9ec823/. Is it a good idea to map it to the user .cargo cache? Like ~/.cargo/?

I suppose, these are dependencies, and all the necessary information should be in the compiled executable (or pdb on windows).

Also, the "auto" value prevents user from adding custom source mappings.

This is intentional. Conflicts are possible if you automatically add a value to the existing source map. And it's easy to forget and then spend a lot of time trying to figure out the reason. Trust me, I've done that before :)

@EFanZh

EFanZh commented Apr 23, 2021

Copy link
Copy Markdown

The /cargo dependencies are likely to be dependencies used by standard libraries.

For example, this command on my PC:

nm -Cl ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-b1047a2788193be4.so | grep /cargo

shows many symbols that have paths start with /cargo/. This library is distributed with the Rust toolchain.

@matklad

matklad commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

bors d+

The code looks OK to me, but I don't really understand the debugging domain at all )

@bors

bors Bot commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

✌️ vsrs can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@vsrs

vsrs commented Apr 27, 2021

Copy link
Copy Markdown
Contributor Author

bors r+

@bors

bors Bot commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

@bors
bors Bot merged commit fb45d2a into rust-lang:master Apr 27, 2021
@lnicola lnicola changed the title Automatically detect rust library source file map feat: Automatically detect rust library source file map Apr 28, 2021
@vsrs
vsrs deleted the auto_src_map branch October 18, 2021 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect Rust library source file map automatically according to the current toolchain

3 participants