-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference completions for nested struct fields put & in wrong location #8058
Comments
I've implemented a quick workaround for this in #8142. I plan to keep working on a proper fix, but I expect that to take a bit longer and it would be nice to fix this bug before the next weekly release. |
The weeklies are Sunday nightlies that get promoted, so this won't get in the release unless we merge it and make a new nightly (I think). This is a pretty annoying issue, but I'm not sure it warrants that. @matklad any thoughts? |
I think it's ok to live with this for another week! |
8142: temp disable broken ref match completions for struct fields/methods r=matklad a=JoshMcguigan This PR implements a temporary workaround for #8058 by disabling ref match completions for struct fields and methods. Disabling this doesn't break any existing functionality (that I am aware of) since these completions were broken. I plan to keep working on a real fix for the underlying issue here, but I think a proper fix could take some time, so I'd prefer to quickly fix the bug to buy some more time to implement a better solution (which would ultimately allow re-enabling ref matches for struct fields and methods). Co-authored-by: Josh Mcguigan <[email protected]>
Now that #8142 has temporarily disabled the buggy/incorrect completions, I'd like to fix this properly so we can re-enable reference completions for struct fields/methods. I think I'd like to start with a refactor:
This should not change any behavior, but should increase the flexibility of the system. This would allow for:
@matklad does this seem reasonable to you? |
I've been digging into this a bit more. I think I made a mistake in #8036 having In my next attempt I'll try moving the |
I implemented this in #8393 but I didn't really like how it turned out for reasons explained in the PR. Next I'll try just adding some marker in the |
Note: we still give erroneous completions in other cases: enum Foo {
Bar,
}
fn foo(f: Foo) {
let _: &Foo = Foo::$0;
// should complete to &Foo::Bar
// actually completes to Foo::&Bar
} and also mod foo {
pub fn bar() -> u32 { 0 }
}
fn foo(f: Foo) {
let _: &u32 = foo::$0;
// should complete to &foo::bar()
// actually completes to foo::&bar()
} |
I.e. don't suggest `Foo::&foo()`. CC rust-lang#8058.
11831: fix: Disable ref_match for qualified paths as well r=flodiebold a=flodiebold I.e. don't suggest `Foo::&foo()`. CC #8058. Co-authored-by: Florian Diebold <[email protected]>
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 newCompletionItem
? Because right nowto_proto
is trying to make sense of how to apply the reference, but that seems like it should be the responsibility of theide_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.
The text was updated successfully, but these errors were encountered: