mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
fix: find Self
reference
This commit is contained in:
parent
3b7c7f97e4
commit
e0276dc5dd
@ -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() =>
|
||||
{
|
||||
let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax());
|
||||
let reference = FileReference {
|
||||
|
@ -683,6 +683,32 @@ enum Foo {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_self() {
|
||||
check(
|
||||
r#"
|
||||
struct S$0<T> {
|
||||
t: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> S<T> {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
t: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
S Struct FileId(0) 0..38 7..8
|
||||
|
||||
FileId(0) 48..49
|
||||
FileId(0) 71..75
|
||||
FileId(0) 86..90
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_all_refs_two_modules() {
|
||||
check(
|
||||
|
Loading…
Reference in New Issue
Block a user