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
fix: find Self
reference
#15864
fix: find Self
reference
#15864
Conversation
@bors r+ |
☀️ Test successful - checks-actions |
@@ -584,7 +584,7 @@ impl<'a> FindUsages<'a> { | |||
) -> bool { | |||
match NameRefClass::classify(self.sema, name_ref) { | |||
Some(NameRefClass::Definition(Definition::SelfType(impl_))) | |||
if impl_.self_ty(self.sema.db) == *self_ty => | |||
if impl_.self_ty(self.sema.db).as_adt() == self_ty.as_adt() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this doesn't seem right to me, now we discard any other type that could appear as the self type in an impl. I'm curious as to why this equality fails in the given example in the first place. Sounds like we are losing some type info along the way somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious too. debug to that point and found the unequality. Is there anyother type for Self
in an impl
beside Adt
?
Actually I don't quite understand the whole implementation of find refenence, it‘s complicated for me :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trait T {}
impl T for fn() {}
is an example. Don't think you can trigger references
highlighting on that, but other code might require the Self
resolution in search to work for that. I can take a look at that next week and see what's going on here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yes, the reference search is pretty messy looking and undocumented so I don't blame you for not being able to fully grasp the implementation there :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah the problem is that the self_ty
here contains an {error}
for the generic param where as the impl.self_ty()
returns the struct with a var for the generic parameter, so the equality check fails. Hm
took a lot of time to debug to find the problem, here should compare the actual
Adt
typeclose #12693