Stream: t-compiler/rust-analyzer

Topic: dev-dependencies are just dependencies to RA, right?


woody77 (May 07 2021 at 20:46, on Zulip):

If I'm reading https://github.com/rust-analyzer/rust-analyzer/blob/ba8620398713d6f116dd1cce1a7e1cd6e3f97461/crates/project_model/src/cargo_workspace.rs#L300 correctly, all of a crates deps are nodes in the dependency graph, and the DependencyKind distinction as determined by cargo-metadata is ignored.

And so when you're looking at a file, the symbols are coming from both the crate itself, and all of its dependencies and dev-dependencies from Cargo.toml?

matklad (May 07 2021 at 20:49, on Zulip):

Yeah, this seems correct

matklad (May 07 2021 at 20:49, on Zulip):

we actually want to do proper splitting of the crate into test and non-test in this sprint, but, IIRC, no one is actively working on it

Jonas Schievink [he/him] (May 07 2021 at 21:07, on Zulip):

I took a brief look today but haven't made much progress

Jonas Schievink [he/him] (May 07 2021 at 21:08, on Zulip):

(there's a very weird bug when using RA on rustc that I was hoping to fix with this, but I'm not sure it's the same one)

woody77 (May 12 2021 at 16:49, on Zulip):

haha.. And I have a change for GN to do the opposite in its rust-project.json generation that I've been working on: combining the test and non-test crate entries together.

woody77 (May 12 2021 at 16:50, on Zulip):

Mostly because what we see is that the test-only deps all end up as unresolved symbols, as a source file gets mapped to the first-found crate entry, which is usually a non-test entry.

woody77 (May 12 2021 at 16:51, on Zulip):

But if there's work to support multiple "crates" per file, with different configs (at least for test), that's _great_, and I'll hold off any more work in that direction.

Jonas Schievink [he/him] (May 12 2021 at 16:54, on Zulip):

woody77 said:

Mostly because what we see is that the test-only deps all end up as unresolved symbols, as a source file gets mapped to the first-found crate entry, which is usually a non-test entry.

we should fix this to choose the crate with the most enabled features (or some other heuristic)

Jonas Schievink [he/him] (May 12 2021 at 16:55, on Zulip):

we'll need it when we instantiate a crate multiple times anyways

woody77 (May 12 2021 at 18:44, on Zulip):

I know @Paul Faria has been thinking off and on about how to select a "configuration".

woody77 (May 12 2021 at 18:46, on Zulip):

TBH, our rust-project.json is unlikely to be what was really what was originally intended, as we often have 4 or more entries for the same root_module source file (lib.rs or main.rs):

Paul Faria (May 12 2021 at 18:46, on Zulip):

I should be getting more time to work on this starting next week. I've also started working on a doc to help align the questions and goals. I think I was trying to tackle too many problems at once the last time I worked on this

Paul Faria (May 12 2021 at 18:48, on Zulip):

The 4 targets above was what caused me a lot of trouble last time. It wasn't clear, given only a file path and a line, how to map which of the 4 crates above the query should be done against.

woody77 (May 12 2021 at 18:50, on Zulip):

And so one of my side investigations has been to take all ~5700 crate entries and combine the duplicate root_modules into the 3700 or so "crates" that RA is expecting.

woody77 (May 12 2021 at 18:51, on Zulip):

Also, RA, during initialization, only lists the unique root_modules when going through its "indexing" phase, not the full count of the crate entries.

Jonas Schievink [he/him] (May 12 2021 at 19:00, on Zulip):

it should index all crates in the constructed crate graph

Jonas Schievink [he/him] (May 12 2021 at 19:00, on Zulip):

there's now a "View Crate Graph" command, maybe that helps debug?

woody77 (Jun 04 2021 at 22:28, on Zulip):

One of the sources of duplication we have is that our build (and therefore our rust-project.json) is a mix of "host" and "target" compilation, using different arguments for rustc (different architectures, optimization, etc).

woody77 (Jun 04 2021 at 22:29, on Zulip):

So there's a fair bit of duplication vs. what Cargo.toml contains. and I've been sorting out how to best merge everything into fewer entries, that looks more like what RA expects from a Cargo.toml project)

Last update: Jul 27 2021 at 22:15UTC