mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
use Source for StructField
This commit is contained in:
parent
8b94b429e5
commit
178d8e96b5
5 changed files with 17 additions and 10 deletions
|
@ -346,13 +346,20 @@ pub enum FieldSource {
|
|||
Pos(TreeArc<ast::PosFieldDef>),
|
||||
}
|
||||
|
||||
impl HasSource for StructField {
|
||||
type Ast = FieldSource;
|
||||
fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<FieldSource> {
|
||||
self.source_impl(db).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl StructField {
|
||||
pub fn name(&self, db: &impl HirDatabase) -> Name {
|
||||
self.parent.variant_data(db).fields().unwrap()[self.id].name.clone()
|
||||
}
|
||||
|
||||
pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> (HirFileId, FieldSource) {
|
||||
self.source_impl(db)
|
||||
pub fn source(&self, db: &(impl DefDatabase + AstDatabase)) -> Source<FieldSource> {
|
||||
self.source_impl(db).into()
|
||||
}
|
||||
|
||||
pub fn ty(&self, db: &impl HirDatabase) -> Ty {
|
||||
|
|
|
@ -72,7 +72,7 @@ pub(crate) fn documentation_query(
|
|||
) -> Option<Documentation> {
|
||||
match def {
|
||||
DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.1),
|
||||
DocDef::StructField(it) => match it.source(db).1 {
|
||||
DocDef::StructField(it) => match it.source(db).ast {
|
||||
FieldSource::Named(named) => docs_from_ast(&*named),
|
||||
FieldSource::Pos(..) => return None,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue