mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Merge #5311
5311: Fix goto definition for type alias type parameters r=matklad a=matklad closes https://github.com/rust-analyzer/rust-analyzer/issues/5042 bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
ba48c6548c
3 changed files with 18 additions and 0 deletions
|
@ -485,6 +485,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
ChildContainer::ModuleId(it) => it.resolver(self.db.upcast()),
|
||||
ChildContainer::EnumId(it) => it.resolver(self.db.upcast()),
|
||||
ChildContainer::VariantId(it) => it.resolver(self.db.upcast()),
|
||||
ChildContainer::TypeAliasId(it) => it.resolver(self.db.upcast()),
|
||||
ChildContainer::GenericDefId(it) => it.resolver(self.db.upcast()),
|
||||
};
|
||||
SourceAnalyzer::new_for_resolver(resolver, src)
|
||||
|
|
|
@ -194,6 +194,10 @@ impl SourceToDefCtx<'_, '_> {
|
|||
let def = self.const_to_def(container.with_value(it))?;
|
||||
DefWithBodyId::from(def).into()
|
||||
},
|
||||
ast::TypeAliasDef(it) => {
|
||||
let def = self.type_alias_to_def(container.with_value(it))?;
|
||||
def.into()
|
||||
},
|
||||
_ => continue,
|
||||
}
|
||||
};
|
||||
|
@ -246,6 +250,7 @@ pub(crate) enum ChildContainer {
|
|||
ImplId(ImplId),
|
||||
EnumId(EnumId),
|
||||
VariantId(VariantId),
|
||||
TypeAliasId(TypeAliasId),
|
||||
/// XXX: this might be the same def as, for example an `EnumId`. However,
|
||||
/// here the children generic parameters, and not, eg enum variants.
|
||||
GenericDefId(GenericDefId),
|
||||
|
@ -258,6 +263,7 @@ impl_froms! {
|
|||
ImplId,
|
||||
EnumId,
|
||||
VariantId,
|
||||
TypeAliasId,
|
||||
GenericDefId
|
||||
}
|
||||
|
||||
|
@ -271,6 +277,7 @@ impl ChildContainer {
|
|||
ChildContainer::ImplId(it) => it.child_by_source(db),
|
||||
ChildContainer::EnumId(it) => it.child_by_source(db),
|
||||
ChildContainer::VariantId(it) => it.child_by_source(db),
|
||||
ChildContainer::TypeAliasId(_) => DynMap::default(),
|
||||
ChildContainer::GenericDefId(it) => it.child_by_source(db),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -856,4 +856,14 @@ impl Foo {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn goto_def_for_type_alias_generic_parameter() {
|
||||
check(
|
||||
r#"
|
||||
type Alias<T> = T<|>;
|
||||
//^
|
||||
"#,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue