aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/has_source.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-14 15:15:52 +0000
committerGitHub <[email protected]>2020-12-14 15:15:52 +0000
commit817fbebbb5f9187994b1a09a603ba9c7b2755a06 (patch)
tree7f5d35fc2aad9880c6c7573d76ef0947c7b613fc /crates/hir/src/has_source.rs
parent134c7563be05d120ffb45d9b971ba95735a0fcb5 (diff)
parentc6172f3f6d3fb0982ae17f48507608609d46d179 (diff)
Merge #6862
6862: Add LifetimeParam resolving to Semantics r=matklad a=Veykril This is stuff required for the lifetime references/definitions PR. I pulled this out to make it easier to review as well as because there is one thing that still has to be addressed which can be found in the review comments. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir/src/has_source.rs')
-rw-r--r--crates/hir/src/has_source.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index c77494152..1e64a1614 100644
--- a/crates/hir/src/has_source.rs
+++ b/crates/hir/src/has_source.rs
@@ -10,8 +10,8 @@ use hir_expand::InFile;
10use syntax::ast; 10use syntax::ast;
11 11
12use crate::{ 12use crate::{
13 db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef, 13 db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef,
14 Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, 14 LifetimeParam, MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
15}; 15};
16 16
17pub trait HasSource { 17pub trait HasSource {
@@ -129,6 +129,14 @@ impl HasSource for TypeParam {
129 type Ast = Either<ast::Trait, ast::TypeParam>; 129 type Ast = Either<ast::Trait, ast::TypeParam>;
130 fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> { 130 fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
131 let child_source = self.id.parent.child_source(db.upcast()); 131 let child_source = self.id.parent.child_source(db.upcast());
132 child_source.map(|it| it[self.id.local_id].clone()) 132 child_source.map(|it| it.type_params[self.id.local_id].clone())
133 }
134}
135
136impl HasSource for LifetimeParam {
137 type Ast = ast::LifetimeParam;
138 fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
139 let child_source = self.id.parent.child_source(db.upcast());
140 child_source.map(|it| it.lifetime_params[self.id.local_id].clone())
133 } 141 }
134} 142}