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
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.
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?
So I think
classify_**name** should always just return a definition, as the namespaces can be inferred from the def itself
for name_ref, yeah, those can be genuinely multinamespaced
but I think only in actual uses?
use serde::Sedialize is both a macro and a trait
So I think we need to do two things:
As for fixing the actual bugs, I think they might be related to https://github.com/rust-analyzer/rust-analyzer/issues/3407
Yes only use statements should have multinamespaced NameRefs I believe.
The bugs do seem related to that issue, which looks like a quite tough one.
@Lukas Wirth you have a talent for poking at "we need to rewrite the underlying abstraction" issues in rust-analyzer ) This is sooo helpful!)
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