mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Lower and handle trait aliases in HIR
This commit is contained in:
parent
e2ec3a6561
commit
29c957f973
47 changed files with 334 additions and 75 deletions
|
@ -11,7 +11,7 @@ use syntax::ast;
|
|||
|
||||
use crate::{
|
||||
db::HirDatabase, Adt, Const, Enum, Field, FieldSource, Function, Impl, LifetimeParam, Macro,
|
||||
Module, Static, Struct, Trait, TypeAlias, TypeOrConstParam, Union, Variant,
|
||||
Module, Static, Struct, Trait, TraitAlias, TypeAlias, TypeOrConstParam, Union, Variant,
|
||||
};
|
||||
|
||||
pub trait HasSource {
|
||||
|
@ -122,6 +122,12 @@ impl HasSource for Trait {
|
|||
Some(self.id.lookup(db.upcast()).source(db.upcast()))
|
||||
}
|
||||
}
|
||||
impl HasSource for TraitAlias {
|
||||
type Ast = ast::TraitAlias;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
Some(self.id.lookup(db.upcast()).source(db.upcast()))
|
||||
}
|
||||
}
|
||||
impl HasSource for TypeAlias {
|
||||
type Ast = ast::TypeAlias;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
|
@ -158,7 +164,7 @@ impl HasSource for Impl {
|
|||
}
|
||||
|
||||
impl HasSource for TypeOrConstParam {
|
||||
type Ast = Either<ast::TypeOrConstParam, ast::Trait>;
|
||||
type Ast = Either<ast::TypeOrConstParam, ast::TraitOrAlias>;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
let child_source = self.id.parent.child_source(db.upcast());
|
||||
Some(child_source.map(|it| it[self.id.local_id].clone()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue