Stream: t-compiler/rust-analyzer

Topic: find usages does not find field usages in patterns

Jonas Schievink [he/him] (Oct 09 2020 at 15:30, on Zulip):
struct S {
    field<|>: u8,

fn f(s: S) {
    match s {
        S { field } => {}

Invoking find usages on the above snippet does not find the field usage in the match. This happens presumably because ident patterns contain a ast::Name, not an ast::NameRef. What would be the correct way to fix this?

It seems to me that we'd have to change classify_name_ref to take something like Either<ast::Name, ast::NameRef>, or add an extra method that works with ast::Name. Of course, changing the AST to use ast::NameRef would also work, but IIRC that's intentional?

Jonas Schievink [he/him] (Oct 09 2020 at 15:39, on Zulip):

Ah nevermind, classify_name already exists

matklad (Oct 11 2020 at 14:18, on Zulip):

Yeah, classify infra is well-prepared for handing such special cases of mixed ref/def (its actually the reason for this infra to exist in the first place)

matklad (Oct 11 2020 at 14:20, on Zulip):

Fun bit of trivia -- Kotlin devs have a royal pain with implementing find usages for fields, as named fields can be used positionaly:

Last update: Jul 26 2021 at 14:15UTC