Stream: t-compiler/rust-analyzer

Topic: Get crate " declaration name"

Kirill Bulatov (Mar 06 2020 at 07:30, on Zulip):

I'm looking at the issue

So far I've got something like this:

(note that input string on the top, this is the mod path).

But then I look at what intellij-rust does and see a crate "name" there:

This way it looks way better, imo.

Yet, we lack the proper way to get that name, since the only crate-related names we operate is a name of a crate that is declared as a dependency.
Is there a way to get the name of a crate that is used when the crate is declared?

matklad (Mar 06 2020 at 08:30, on Zulip):

Not really at the moment

matklad (Mar 06 2020 at 08:31, on Zulip):

It would be fine to add this info to ra_ide crate, but not to the hir. We used to have something similar for debugging infra, but we removed it when we split the hir

Kirill Bulatov (Mar 06 2020 at 09:23, on Zulip):

If you share a pointer to the removal PR, it will help.

std::Veetaha (Mar 06 2020 at 09:39, on Zulip):

I thought you were talking about this debugging infra, but it wasn't removed

matklad (Mar 06 2020 at 09:40, on Zulip):

Kirill Bulatov (Mar 08 2020 at 11:59, on Zulip):

What if we add the crate name info to ra_db level instead, making the CrateData to contain the declaration_name (or whatever better name used) with the property required?
add_crate_root method can accept one more parameter.

Kirill Bulatov (Mar 08 2020 at 12:03, on Zulip):

The main issue would be to get some name for the project.json case (, so we can keep this property Optional for a while or use some dummy values for those crates instead.

matklad (Mar 08 2020 at 12:33, on Zulip):

I now think that maybe we should store an optional display name in
CrateGraph? It would be useful for profiling as well at least and,
practically, it should be hard to misuse.

Kirill Bulatov (Mar 08 2020 at 12:56, on Zulip):

CrateData is also in the CrateGraph, so we're talking almost about the same.
I'm a bit reluctant to make it optional, since every crate has its own declaration name, doesn't it?

Kirill Bulatov (Mar 08 2020 at 14:15, on Zulip):

Actually, never mind, it should be optional, I've confused different kinds of crate names.

Last update: Jul 29 2021 at 08:30UTC