fix: only ref match non-unknown value items#22367
Merged
Merged
Conversation
Example
---
```rust
struct S<T>(T);
impl<T> core::ops::Deref for S<T> {
type Target = T;
}
fn foo<T>(s: &u32) {}
fn main() {
let ssss = S();
foo($0);
}
```
**Before this PR**
```text
lc ssss S<{unknown}> [local]
lc &ssss [type+local]
st S S<{unknown}> []
st &S [type]
...
```
**After this PR**
```text
lc ssss S<{unknown}> [local]
st S S<{unknown}> []
...
```
Member
Author
|
r? @ChayimFriedman2 This needs to be fixed as soon as possible, otherwise any Deref to generic will be auto imported Example Completes |
| match resolution { | ||
| ScopeDef::Local(_) | ||
| | ScopeDef::ModuleDef(ModuleDef::Const(_) | ModuleDef::Static(_)) => { | ||
| path_ref_match(completion, path_ctx, &ty, &mut item) |
Contributor
There was a problem hiding this comment.
Why do you know filter to only consts/statics/locals?
Member
Author
There was a problem hiding this comment.
For struct paths, etc., the assoc fn may not necessarily return Self, and it is suggest to reference noise
And if its method is still ref match, it can be done when completing the method e.g f(Foo::ne) -> f(&Foo::new())
Contributor
There was a problem hiding this comment.
But this will also prevent struct literals from adding a ref, e.g. Foo { ... } or Foo(...).
Member
Author
There was a problem hiding this comment.
No, this is not. The test was not broken, and it was rendered by literal instead of path
A4-Tacks
commented
May 17, 2026
| st WorldSnapshot {…} WorldSnapshot { _f: () } [] | ||
| st &WorldSnapshot {…} [type] | ||
| st WorldSnapshot WorldSnapshot [] | ||
| st &WorldSnapshot [type] |
ChayimFriedman2
approved these changes
May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22324
Example
Before this PR
After this PR