mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Infallible definition hovers
This commit is contained in:
parent
2223b4fa71
commit
a822291a02
5 changed files with 135 additions and 38 deletions
|
@ -213,8 +213,8 @@ impl Definition {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn label(&self, db: &RootDatabase) -> Option<String> {
|
||||
let label = match *self {
|
||||
pub fn label(&self, db: &RootDatabase) -> String {
|
||||
match *self {
|
||||
Definition::Macro(it) => it.display(db).to_string(),
|
||||
Definition::Field(it) => it.display(db).to_string(),
|
||||
Definition::TupleField(it) => it.display(db).to_string(),
|
||||
|
@ -241,7 +241,11 @@ impl Definition {
|
|||
}
|
||||
}
|
||||
Definition::SelfType(impl_def) => {
|
||||
impl_def.self_ty(db).as_adt().and_then(|adt| Definition::Adt(adt).label(db))?
|
||||
let self_ty = &impl_def.self_ty(db);
|
||||
match self_ty.as_adt() {
|
||||
Some(it) => it.display(db).to_string(),
|
||||
None => self_ty.display(db).to_string(),
|
||||
}
|
||||
}
|
||||
Definition::GenericParam(it) => it.display(db).to_string(),
|
||||
Definition::Label(it) => it.name(db).display(db).to_string(),
|
||||
|
@ -249,8 +253,7 @@ impl Definition {
|
|||
Definition::BuiltinAttr(it) => format!("#[{}]", it.name(db)),
|
||||
Definition::ToolModule(it) => it.name(db).to_string(),
|
||||
Definition::DeriveHelper(it) => format!("derive_helper {}", it.name(db).display(db)),
|
||||
};
|
||||
Some(label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue