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 https://github.com/rust-analyzer/rust-analyzer/issues/7408 and https://github.com/rust-analyzer/rust-analyzer/issues/7479 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 https://github.com/rust-analyzer/rust-analyzer/issues/3407

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

:sweat_smile:

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 https://github.com/rust-analyzer/rust-analyzer/pull/7483 we were indeed simply missing a check here https://github.com/rust-analyzer/rust-analyzer/pull/7483/files#diff-0da7dd327a598aadb8c360d534aedf26f76c26b5a877a6a543649323509e3aecR236-R238

Last update: Jul 26 2021 at 14:00UTC