mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
feat: Show notable trait impls on hover
This commit is contained in:
parent
384488c157
commit
82e8355492
7 changed files with 556 additions and 374 deletions
|
@ -2844,6 +2844,7 @@ impl AssocItem {
|
|||
AssocItem::TypeAlias(it) => Some(it.name(db)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
||||
match self {
|
||||
AssocItem::Function(f) => f.module(db),
|
||||
|
@ -2851,6 +2852,7 @@ impl AssocItem {
|
|||
AssocItem::TypeAlias(t) => t.module(db),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn container(self, db: &dyn HirDatabase) -> AssocItemContainer {
|
||||
let container = match self {
|
||||
AssocItem::Function(it) => it.id.lookup(db.upcast()).container,
|
||||
|
@ -2886,6 +2888,27 @@ impl AssocItem {
|
|||
AssocItemContainer::Impl(i) => i.trait_(db),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_function(self) -> Option<Function> {
|
||||
match self {
|
||||
Self::Function(v) => Some(v),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_const(self) -> Option<Const> {
|
||||
match self {
|
||||
Self::Const(v) => Some(v),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_type_alias(self) -> Option<TypeAlias> {
|
||||
match self {
|
||||
Self::TypeAlias(v) => Some(v),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HasVisibility for AssocItem {
|
||||
|
@ -3024,6 +3047,7 @@ impl LocalSource {
|
|||
|
||||
impl Local {
|
||||
pub fn is_param(self, db: &dyn HirDatabase) -> bool {
|
||||
// FIXME: This parses!
|
||||
let src = self.primary_source(db);
|
||||
match src.source.value {
|
||||
Either::Left(pat) => pat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue