aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/code_model.rs41
-rw-r--r--crates/hir/src/db.rs4
-rw-r--r--crates/hir/src/from_id.rs6
-rw-r--r--crates/hir/src/has_source.rs10
-rw-r--r--crates/hir/src/lib.rs2
-rw-r--r--crates/hir/src/semantics.rs23
-rw-r--r--crates/hir/src/semantics/source_to_def.rs4
7 files changed, 45 insertions, 45 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 7ffa79996..3248f6d20 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -267,7 +267,12 @@ impl ModuleDef {
267 _ => return, 267 _ => return,
268 }; 268 };
269 269
270 hir_ty::diagnostics::validate_module_item(db, id, sink) 270 let module = match self.module(db) {
271 Some(it) => it,
272 None => return,
273 };
274
275 hir_ty::diagnostics::validate_module_item(db, module.id.krate, id, sink)
271 } 276 }
272} 277}
273 278
@@ -397,9 +402,9 @@ impl Module {
397 def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect() 402 def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect()
398 } 403 }
399 404
400 pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<ImplDef> { 405 pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
401 let def_map = db.crate_def_map(self.id.krate); 406 let def_map = db.crate_def_map(self.id.krate);
402 def_map[self.id.local_id].scope.impls().map(ImplDef::from).collect() 407 def_map[self.id.local_id].scope.impls().map(Impl::from).collect()
403 } 408 }
404 409
405 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module { 410 pub(crate) fn with_module_id(self, module_id: LocalModuleId) -> Module {
@@ -780,8 +785,9 @@ impl Function {
780 } 785 }
781 786
782 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { 787 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
788 let krate = self.module(db).id.krate;
783 hir_def::diagnostics::validate_body(db.upcast(), self.id.into(), sink); 789 hir_def::diagnostics::validate_body(db.upcast(), self.id.into(), sink);
784 hir_ty::diagnostics::validate_module_item(db, self.id.into(), sink); 790 hir_ty::diagnostics::validate_module_item(db, krate, self.id.into(), sink);
785 hir_ty::diagnostics::validate_body(db, self.id.into(), sink); 791 hir_ty::diagnostics::validate_body(db, self.id.into(), sink);
786 } 792 }
787 793
@@ -970,7 +976,7 @@ impl MacroDef {
970 /// defines this macro. The reasons for this is that macros are expanded 976 /// defines this macro. The reasons for this is that macros are expanded
971 /// early, in `hir_expand`, where modules simply do not exist yet. 977 /// early, in `hir_expand`, where modules simply do not exist yet.
972 pub fn module(self, db: &dyn HirDatabase) -> Option<Module> { 978 pub fn module(self, db: &dyn HirDatabase) -> Option<Module> {
973 let krate = self.id.krate?; 979 let krate = self.id.krate;
974 let module_id = db.crate_def_map(krate).root; 980 let module_id = db.crate_def_map(krate).root;
975 Some(Module::new(Crate { id: krate }, module_id)) 981 Some(Module::new(Crate { id: krate }, module_id))
976 } 982 }
@@ -1007,7 +1013,7 @@ pub enum AssocItem {
1007} 1013}
1008pub enum AssocItemContainer { 1014pub enum AssocItemContainer {
1009 Trait(Trait), 1015 Trait(Trait),
1010 ImplDef(ImplDef), 1016 Impl(Impl),
1011} 1017}
1012pub trait AsAssocItem { 1018pub trait AsAssocItem {
1013 fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem>; 1019 fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem>;
@@ -1064,7 +1070,7 @@ impl AssocItem {
1064 }; 1070 };
1065 match container { 1071 match container {
1066 AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()), 1072 AssocContainerId::TraitId(id) => AssocItemContainer::Trait(id.into()),
1067 AssocContainerId::ImplId(id) => AssocItemContainer::ImplDef(id.into()), 1073 AssocContainerId::ImplId(id) => AssocItemContainer::Impl(id.into()),
1068 AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"), 1074 AssocContainerId::ContainerId(_) => panic!("invalid AssocItem"),
1069 } 1075 }
1070 } 1076 }
@@ -1086,7 +1092,7 @@ pub enum GenericDef {
1086 Adt(Adt), 1092 Adt(Adt),
1087 Trait(Trait), 1093 Trait(Trait),
1088 TypeAlias(TypeAlias), 1094 TypeAlias(TypeAlias),
1089 ImplDef(ImplDef), 1095 Impl(Impl),
1090 // enum variants cannot have generics themselves, but their parent enums 1096 // enum variants cannot have generics themselves, but their parent enums
1091 // can, and this makes some code easier to write 1097 // can, and this makes some code easier to write
1092 EnumVariant(EnumVariant), 1098 EnumVariant(EnumVariant),
@@ -1098,7 +1104,7 @@ impl_from!(
1098 Adt(Struct, Enum, Union), 1104 Adt(Struct, Enum, Union),
1099 Trait, 1105 Trait,
1100 TypeAlias, 1106 TypeAlias,
1101 ImplDef, 1107 Impl,
1102 EnumVariant, 1108 EnumVariant,
1103 Const 1109 Const
1104 for GenericDef 1110 for GenericDef
@@ -1268,30 +1274,28 @@ impl LifetimeParam {
1268 1274
1269// FIXME: rename from `ImplDef` to `Impl` 1275// FIXME: rename from `ImplDef` to `Impl`
1270#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 1276#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1271pub struct ImplDef { 1277pub struct Impl {
1272 pub(crate) id: ImplId, 1278 pub(crate) id: ImplId,
1273} 1279}
1274 1280
1275impl ImplDef { 1281impl Impl {
1276 pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec<ImplDef> { 1282 pub fn all_in_crate(db: &dyn HirDatabase, krate: Crate) -> Vec<Impl> {
1277 let inherent = db.inherent_impls_in_crate(krate.id); 1283 let inherent = db.inherent_impls_in_crate(krate.id);
1278 let trait_ = db.trait_impls_in_crate(krate.id); 1284 let trait_ = db.trait_impls_in_crate(krate.id);
1279 1285
1280 inherent.all_impls().chain(trait_.all_impls()).map(Self::from).collect() 1286 inherent.all_impls().chain(trait_.all_impls()).map(Self::from).collect()
1281 } 1287 }
1282 pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec<ImplDef> { 1288 pub fn for_trait(db: &dyn HirDatabase, krate: Crate, trait_: Trait) -> Vec<Impl> {
1283 let impls = db.trait_impls_in_crate(krate.id); 1289 let impls = db.trait_impls_in_crate(krate.id);
1284 impls.for_trait(trait_.id).map(Self::from).collect() 1290 impls.for_trait(trait_.id).map(Self::from).collect()
1285 } 1291 }
1286 1292
1293 // FIXME: the return type is wrong. This should be a hir version of
1294 // `TraitRef` (ie, resolved `TypeRef`).
1287 pub fn target_trait(self, db: &dyn HirDatabase) -> Option<TypeRef> { 1295 pub fn target_trait(self, db: &dyn HirDatabase) -> Option<TypeRef> {
1288 db.impl_data(self.id).target_trait.clone() 1296 db.impl_data(self.id).target_trait.clone()
1289 } 1297 }
1290 1298
1291 pub fn target_type(self, db: &dyn HirDatabase) -> TypeRef {
1292 db.impl_data(self.id).target_type.clone()
1293 }
1294
1295 pub fn target_ty(self, db: &dyn HirDatabase) -> Type { 1299 pub fn target_ty(self, db: &dyn HirDatabase) -> Type {
1296 let impl_data = db.impl_data(self.id); 1300 let impl_data = db.impl_data(self.id);
1297 let resolver = self.id.resolver(db.upcast()); 1301 let resolver = self.id.resolver(db.upcast());
@@ -1325,6 +1329,7 @@ impl ImplDef {
1325 let item = src.file_id.is_builtin_derive(db.upcast())?; 1329 let item = src.file_id.is_builtin_derive(db.upcast())?;
1326 let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id); 1330 let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id);
1327 1331
1332 // FIXME: handle `cfg_attr`
1328 let attr = item 1333 let attr = item
1329 .value 1334 .value
1330 .attrs() 1335 .attrs()
@@ -1904,7 +1909,7 @@ pub enum ScopeDef {
1904 ModuleDef(ModuleDef), 1909 ModuleDef(ModuleDef),
1905 MacroDef(MacroDef), 1910 MacroDef(MacroDef),
1906 GenericParam(TypeParam), 1911 GenericParam(TypeParam),
1907 ImplSelfType(ImplDef), 1912 ImplSelfType(Impl),
1908 AdtSelfType(Adt), 1913 AdtSelfType(Adt),
1909 Local(Local), 1914 Local(Local),
1910 Unknown, 1915 Unknown,
diff --git a/crates/hir/src/db.rs b/crates/hir/src/db.rs
index 8d949b264..d01e1b33d 100644
--- a/crates/hir/src/db.rs
+++ b/crates/hir/src/db.rs
@@ -6,8 +6,8 @@ pub use hir_def::db::{
6 FunctionDataQuery, GenericParamsQuery, ImplDataQuery, ImportMapQuery, InternConstQuery, 6 FunctionDataQuery, GenericParamsQuery, ImplDataQuery, ImportMapQuery, InternConstQuery,
7 InternDatabase, InternDatabaseStorage, InternEnumQuery, InternFunctionQuery, InternImplQuery, 7 InternDatabase, InternDatabaseStorage, InternEnumQuery, InternFunctionQuery, InternImplQuery,
8 InternStaticQuery, InternStructQuery, InternTraitQuery, InternTypeAliasQuery, InternUnionQuery, 8 InternStaticQuery, InternStructQuery, InternTraitQuery, InternTypeAliasQuery, InternUnionQuery,
9 ItemTreeQuery, LangItemQuery, ModuleLangItemsQuery, StaticDataQuery, StructDataQuery, 9 ItemTreeQuery, LangItemQuery, StaticDataQuery, StructDataQuery, TraitDataQuery,
10 TraitDataQuery, TypeAliasDataQuery, UnionDataQuery, 10 TypeAliasDataQuery, UnionDataQuery,
11}; 11};
12pub use hir_expand::db::{ 12pub use hir_expand::db::{
13 AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery, 13 AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery,
diff --git a/crates/hir/src/from_id.rs b/crates/hir/src/from_id.rs
index dd3fcfe4a..8d0f84508 100644
--- a/crates/hir/src/from_id.rs
+++ b/crates/hir/src/from_id.rs
@@ -39,7 +39,7 @@ from_id![
39 (hir_def::StaticId, crate::Static), 39 (hir_def::StaticId, crate::Static),
40 (hir_def::ConstId, crate::Const), 40 (hir_def::ConstId, crate::Const),
41 (hir_def::FunctionId, crate::Function), 41 (hir_def::FunctionId, crate::Function),
42 (hir_def::ImplId, crate::ImplDef), 42 (hir_def::ImplId, crate::Impl),
43 (hir_def::TypeParamId, crate::TypeParam), 43 (hir_def::TypeParamId, crate::TypeParam),
44 (hir_def::LifetimeParamId, crate::LifetimeParam), 44 (hir_def::LifetimeParamId, crate::LifetimeParam),
45 (hir_expand::MacroDefId, crate::MacroDef) 45 (hir_expand::MacroDefId, crate::MacroDef)
@@ -146,7 +146,7 @@ impl From<GenericDef> for GenericDefId {
146 GenericDef::Adt(it) => GenericDefId::AdtId(it.into()), 146 GenericDef::Adt(it) => GenericDefId::AdtId(it.into()),
147 GenericDef::Trait(it) => GenericDefId::TraitId(it.id), 147 GenericDef::Trait(it) => GenericDefId::TraitId(it.id),
148 GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id), 148 GenericDef::TypeAlias(it) => GenericDefId::TypeAliasId(it.id),
149 GenericDef::ImplDef(it) => GenericDefId::ImplId(it.id), 149 GenericDef::Impl(it) => GenericDefId::ImplId(it.id),
150 GenericDef::EnumVariant(it) => { 150 GenericDef::EnumVariant(it) => {
151 GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id }) 151 GenericDefId::EnumVariantId(EnumVariantId { parent: it.parent.id, local_id: it.id })
152 } 152 }
@@ -162,7 +162,7 @@ impl From<GenericDefId> for GenericDef {
162 GenericDefId::AdtId(it) => GenericDef::Adt(it.into()), 162 GenericDefId::AdtId(it) => GenericDef::Adt(it.into()),
163 GenericDefId::TraitId(it) => GenericDef::Trait(it.into()), 163 GenericDefId::TraitId(it) => GenericDef::Trait(it.into()),
164 GenericDefId::TypeAliasId(it) => GenericDef::TypeAlias(it.into()), 164 GenericDefId::TypeAliasId(it) => GenericDef::TypeAlias(it.into()),
165 GenericDefId::ImplId(it) => GenericDef::ImplDef(it.into()), 165 GenericDefId::ImplId(it) => GenericDef::Impl(it.into()),
166 GenericDefId::EnumVariantId(it) => { 166 GenericDefId::EnumVariantId(it) => {
167 GenericDef::EnumVariant(EnumVariant { parent: it.parent.into(), id: it.local_id }) 167 GenericDef::EnumVariant(EnumVariant { parent: it.parent.into(), id: it.local_id })
168 } 168 }
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs
index 04845037f..c5b81b252 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, 13 db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, Impl, LifetimeParam,
14 LifetimeParam, MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union, 14 MacroDef, Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
15}; 15};
16 16
17pub trait HasSource { 17pub trait HasSource {
@@ -110,15 +110,15 @@ impl HasSource for TypeAlias {
110 } 110 }
111} 111}
112impl HasSource for MacroDef { 112impl HasSource for MacroDef {
113 type Ast = ast::MacroRules; 113 type Ast = ast::Macro;
114 fn source(self, db: &dyn HirDatabase) -> InFile<ast::MacroRules> { 114 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Macro> {
115 InFile { 115 InFile {
116 file_id: self.id.ast_id.expect("MacroDef without ast_id").file_id, 116 file_id: self.id.ast_id.expect("MacroDef without ast_id").file_id,
117 value: self.id.ast_id.expect("MacroDef without ast_id").to_node(db.upcast()), 117 value: self.id.ast_id.expect("MacroDef without ast_id").to_node(db.upcast()),
118 } 118 }
119 } 119 }
120} 120}
121impl HasSource for ImplDef { 121impl HasSource for Impl {
122 type Ast = ast::Impl; 122 type Ast = ast::Impl;
123 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> { 123 fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> {
124 self.id.lookup(db.upcast()).source(db.upcast()) 124 self.id.lookup(db.upcast()).source(db.upcast())
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 0f399a2c6..3f4f8d8e4 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -35,7 +35,7 @@ pub use crate::{
35 code_model::{ 35 code_model::{
36 Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const, 36 Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, Callable, CallableKind, Const,
37 Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function, 37 Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource, Function,
38 GenericDef, HasVisibility, ImplDef, LifetimeParam, Local, MacroDef, Module, ModuleDef, 38 GenericDef, HasVisibility, Impl, LifetimeParam, Local, MacroDef, Module, ModuleDef,
39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, 39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef,
40 }, 40 },
41 has_source::HasSource, 41 has_source::HasSource,
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 5959ac4ca..83ec91f58 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -25,7 +25,7 @@ use crate::{
25 diagnostics::Diagnostic, 25 diagnostics::Diagnostic,
26 semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, 26 semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
27 source_analyzer::{resolve_hir_path, SourceAnalyzer}, 27 source_analyzer::{resolve_hir_path, SourceAnalyzer},
28 AssocItem, Callable, Crate, Field, Function, HirFileId, ImplDef, InFile, LifetimeParam, Local, 28 AssocItem, Callable, Crate, Field, Function, HirFileId, Impl, InFile, LifetimeParam, Local,
29 MacroDef, Module, ModuleDef, Name, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, 29 MacroDef, Module, ModuleDef, Name, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam,
30 VariantDef, 30 VariantDef,
31}; 31};
@@ -38,7 +38,7 @@ pub enum PathResolution {
38 Local(Local), 38 Local(Local),
39 /// A generic parameter 39 /// A generic parameter
40 TypeParam(TypeParam), 40 TypeParam(TypeParam),
41 SelfType(ImplDef), 41 SelfType(Impl),
42 Macro(MacroDef), 42 Macro(MacroDef),
43 AssocItem(AssocItem), 43 AssocItem(AssocItem),
44} 44}
@@ -178,9 +178,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
178 self.imp.descend_node_at_offset(node, offset).find_map(N::cast) 178 self.imp.descend_node_at_offset(node, offset).find_map(N::cast)
179 } 179 }
180 180
181 // FIXME: Replace the SyntaxToken with a typed ast Node/Token 181 pub fn resolve_lifetime_param(&self, lifetime: &ast::Lifetime) -> Option<LifetimeParam> {
182 pub fn resolve_lifetime_param(&self, lifetime_token: &SyntaxToken) -> Option<LifetimeParam> { 182 self.imp.resolve_lifetime_param(lifetime)
183 self.imp.resolve_lifetime_param(lifetime_token)
184 } 183 }
185 184
186 pub fn type_of_expr(&self, expr: &ast::Expr) -> Option<Type> { 185 pub fn type_of_expr(&self, expr: &ast::Expr) -> Option<Type> {
@@ -402,13 +401,9 @@ impl<'db> SemanticsImpl<'db> {
402 .kmerge_by(|node1, node2| node1.text_range().len() < node2.text_range().len()) 401 .kmerge_by(|node1, node2| node1.text_range().len() < node2.text_range().len())
403 } 402 }
404 403
405 // FIXME: Replace the SyntaxToken with a typed ast Node/Token 404 fn resolve_lifetime_param(&self, lifetime: &ast::Lifetime) -> Option<LifetimeParam> {
406 fn resolve_lifetime_param(&self, lifetime_token: &SyntaxToken) -> Option<LifetimeParam> { 405 let text = lifetime.text();
407 if lifetime_token.kind() != syntax::SyntaxKind::LIFETIME { 406 let lifetime_param = lifetime.syntax().ancestors().find_map(|syn| {
408 return None;
409 }
410 let lifetime_text = lifetime_token.text();
411 let lifetime_param = lifetime_token.parent().ancestors().find_map(|syn| {
412 let gpl = match_ast! { 407 let gpl = match_ast! {
413 match syn { 408 match syn {
414 ast::Fn(it) => it.generic_param_list()?, 409 ast::Fn(it) => it.generic_param_list()?,
@@ -424,7 +419,7 @@ impl<'db> SemanticsImpl<'db> {
424 } 419 }
425 }; 420 };
426 gpl.lifetime_params() 421 gpl.lifetime_params()
427 .find(|tp| tp.lifetime_token().as_ref().map(|lt| lt.text()) == Some(lifetime_text)) 422 .find(|tp| tp.lifetime().as_ref().map(|lt| lt.text()) == Some(text))
428 })?; 423 })?;
429 let src = self.find_file(lifetime_param.syntax().clone()).with_value(lifetime_param); 424 let src = self.find_file(lifetime_param.syntax().clone()).with_value(lifetime_param);
430 ToDef::to_def(self, src) 425 ToDef::to_def(self, src)
@@ -713,7 +708,7 @@ to_def_impls![
713 (crate::Enum, ast::Enum, enum_to_def), 708 (crate::Enum, ast::Enum, enum_to_def),
714 (crate::Union, ast::Union, union_to_def), 709 (crate::Union, ast::Union, union_to_def),
715 (crate::Trait, ast::Trait, trait_to_def), 710 (crate::Trait, ast::Trait, trait_to_def),
716 (crate::ImplDef, ast::Impl, impl_to_def), 711 (crate::Impl, ast::Impl, impl_to_def),
717 (crate::TypeAlias, ast::TypeAlias, type_alias_to_def), 712 (crate::TypeAlias, ast::TypeAlias, type_alias_to_def),
718 (crate::Const, ast::Const, const_to_def), 713 (crate::Const, ast::Const, const_to_def),
719 (crate::Static, ast::Static, static_to_def), 714 (crate::Static, ast::Static, static_to_def),
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index a333d7aea..3efca5baa 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -157,8 +157,8 @@ impl SourceToDefCtx<'_, '_> {
157 let file_id = src.file_id.original_file(self.db.upcast()); 157 let file_id = src.file_id.original_file(self.db.upcast());
158 let krate = self.file_to_def(file_id)?.krate; 158 let krate = self.file_to_def(file_id)?.krate;
159 let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); 159 let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value);
160 let ast_id = Some(AstId::new(src.file_id, file_ast_id)); 160 let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast()));
161 Some(MacroDefId { krate: Some(krate), ast_id, kind, local_inner: false }) 161 Some(MacroDefId { krate, ast_id, kind, local_inner: false })
162 } 162 }
163 163
164 pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> { 164 pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> {