mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Add LifetimeParam resolving to Semantics
This commit is contained in:
parent
dbd0cfba53
commit
c6172f3f6d
8 changed files with 131 additions and 39 deletions
|
@ -10,8 +10,8 @@ use hir_expand::InFile;
|
|||
use syntax::ast;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef,
|
||||
Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
|
||||
db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef,
|
||||
LifetimeParam, MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
|
||||
};
|
||||
|
||||
pub trait HasSource {
|
||||
|
@ -129,6 +129,14 @@ impl HasSource for TypeParam {
|
|||
type Ast = Either<ast::Trait, ast::TypeParam>;
|
||||
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
|
||||
let child_source = self.id.parent.child_source(db.upcast());
|
||||
child_source.map(|it| it[self.id.local_id].clone())
|
||||
child_source.map(|it| it.type_params[self.id.local_id].clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl HasSource for LifetimeParam {
|
||||
type Ast = ast::LifetimeParam;
|
||||
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
|
||||
let child_source = self.id.parent.child_source(db.upcast());
|
||||
child_source.map(|it| it.lifetime_params[self.id.local_id].clone())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue