Stream: t-compiler/rust-analyzer

Topic: Name classification and namespaces

Lukas Wirth (Jan 28 2021 at 17:14, on Zulip):

Name classification seems to have a "small" problem. We don't classify names correctly if they exist in multiple namespaces, see and for examples

Lukas Wirth (Jan 28 2021 at 17:15, on Zulip):

Basically if a name appears in multiple namespaces we seem to resolve it in the macro, type and then value namespace in that order. So if we find a name in the macro namespace for example we immediately return it and therefor skip going through the type and value namespace even if we actually want the type behind the name.

Lukas Wirth (Jan 28 2021 at 17:17, on Zulip):

On the other hand maybe we just need some more ast matches to fix these two occurences up, I haven't looked at classification too much yet. Actually for semantic highlighting issue I think its just missing a check ye, but the other issue seems a bit more problematic?

matklad (Jan 28 2021 at 17:29, on Zulip):

So I think classify_**name** should always just return a definition, as the namespaces can be inferred from the def itself

matklad (Jan 28 2021 at 17:29, on Zulip):

for name_ref, yeah, those can be genuinely multinamespaced

matklad (Jan 28 2021 at 17:30, on Zulip):

but I think only in actual uses? use serde::Sedialize is both a macro and a trait

matklad (Jan 28 2021 at 17:32, on Zulip):

So I think we need to do two things:

matklad (Jan 28 2021 at 17:35, on Zulip):

As for fixing the actual bugs, I think they might be related to

Lukas Wirth (Jan 28 2021 at 17:46, on Zulip):

Yes only use statements should have multinamespaced NameRefs I believe.

Lukas Wirth (Jan 28 2021 at 17:47, on Zulip):

The bugs do seem related to that issue, which looks like a quite tough one.

matklad (Jan 28 2021 at 17:50, on Zulip):

@Lukas Wirth you have a talent for poking at "we need to rewrite the underlying abstraction" issues in rust-analyzer ) This is sooo helpful!)

Lukas Wirth (Jan 28 2021 at 17:52, on Zulip):


Lukas Wirth (Jan 28 2021 at 18:11, on Zulip):

Without looking too much into the rest, the function calls being shadowed by types was simple to fix we were indeed simply missing a check here

Last update: Jul 26 2021 at 14:00UTC