Stream: t-compiler/wg-rls-2.0

Topic: Get crate " declaration name"


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

I'm looking at the https://github.com/rust-analyzer/rust-analyzer/issues/1064 issue

So far I've got something like this:

image.png
(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:
image.png

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):

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

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

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

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

https://github.com/rust-analyzer/rust-analyzer/commit/ef2b84ddf119c950272c5f1eb321f3f9e90bedd4

https://github.com/rust-analyzer/rust-analyzer/commit/32658a73b4c9078421a1cab92ec459bb5b7236f5

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 (https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/rust-project.2Ejson/near/188152985), so we can keep this property Optional for a while.

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: Sep 30 2020 at 16:15UTC