Skip to content

Reference completions for nested struct fields put & in wrong location #8058

Closed
@JoshMcguigan

Description

@JoshMcguigan
struct Foo {
    bar: u32,
}

fn foo(f: Foo) {
    let _: &u32 = f.$0;
    // should complete to &f.bar
    // actually completes to f.&bar
}

https://github.com/rust-analyzer/rust-analyzer/blob/00c80b208bcbe52b13bbd03cb62e24b2d2075edf/crates/ide_completion/src/item.rs#L340

https://github.com/rust-analyzer/rust-analyzer/blob/00c80b208bcbe52b13bbd03cb62e24b2d2075edf/crates/rust-analyzer/src/to_proto.rs#L247-L260

Perhaps ref_match should return a new CompletionItem? Because right now to_proto is trying to make sense of how to apply the reference, but that seems like it should be the responsibility of the ide_completion crate.

I'm not going to have time to look at this too much further until early next week, so if anyone else is interested please feel free to take this one. Otherwise I'll give it a shot in a week or so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionautocompletionS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions