mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Add trait codegen to add_missing_impl_members
assist
This commit is contained in:
parent
4d2e25a034
commit
d6b788a9ee
5 changed files with 74 additions and 19 deletions
|
@ -10,8 +10,8 @@ use hir_expand::InFile;
|
|||
use syntax::ast;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, Const, ConstParam, Enum, Field, FieldSource, Function, Impl, LifetimeParam,
|
||||
MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
|
||||
db::HirDatabase, Adt, Const, ConstParam, Enum, Field, FieldSource, Function, Impl,
|
||||
LifetimeParam, MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
|
||||
};
|
||||
|
||||
pub trait HasSource {
|
||||
|
@ -56,6 +56,16 @@ impl HasSource for Field {
|
|||
Some(field_source)
|
||||
}
|
||||
}
|
||||
impl HasSource for Adt {
|
||||
type Ast = ast::Adt;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
match self {
|
||||
Adt::Struct(s) => Some(s.source(db)?.map(|s| ast::Adt::Struct(s))),
|
||||
Adt::Union(u) => Some(u.source(db)?.map(|u| ast::Adt::Union(u))),
|
||||
Adt::Enum(e) => Some(e.source(db)?.map(|e| ast::Adt::Enum(e))),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl HasSource for Struct {
|
||||
type Ast = ast::Struct;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue