diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-26 16:16:54 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-26 16:16:54 +0000 |
commit | a82755e24102bea85be450e0b210d45b05b9f246 (patch) | |
tree | 52f347ddfc4586e3dfa4467827b211d1684aaa74 /crates/ra_hir/src/nameres | |
parent | 96acf4f7ec4257af0d5fd0415b31ab6757b475ad (diff) | |
parent | 1325a31e34a3b4bf5104a743bcb8217ef5c4f3cd (diff) |
Merge #1059
1059: Typed ids r=matklad a=matklad
just some type-safety and refactorings.
closes https://github.com/rust-analyzer/rust-analyzer/issues/1054
bors r+
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 69 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 69 |
2 files changed, 70 insertions, 68 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 4fb298155..39cadc94a 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -3,10 +3,11 @@ use rustc_hash::FxHashMap; | |||
3 | use relative_path::RelativePathBuf; | 3 | use relative_path::RelativePathBuf; |
4 | use test_utils::tested_by; | 4 | use test_utils::tested_by; |
5 | use ra_db::FileId; | 5 | use ra_db::FileId; |
6 | use ra_syntax::ast; | ||
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | Function, Module, Struct, Enum, Const, Static, Trait, TypeAlias, | 9 | Function, Module, Struct, Enum, Const, Static, Trait, TypeAlias, |
9 | DefDatabase, HirFileId, Name, Path, SourceItemId, | 10 | DefDatabase, HirFileId, Name, Path, |
10 | KnownName, | 11 | KnownName, |
11 | nameres::{ | 12 | nameres::{ |
12 | Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, | 13 | Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, |
@@ -15,6 +16,7 @@ use crate::{ | |||
15 | raw, | 16 | raw, |
16 | }, | 17 | }, |
17 | ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId}, | 18 | ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId}, |
19 | AstId, | ||
18 | }; | 20 | }; |
19 | 21 | ||
20 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 22 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -51,7 +53,7 @@ struct DefCollector<DB> { | |||
51 | def_map: CrateDefMap, | 53 | def_map: CrateDefMap, |
52 | glob_imports: FxHashMap<CrateModuleId, Vec<(CrateModuleId, raw::ImportId)>>, | 54 | glob_imports: FxHashMap<CrateModuleId, Vec<(CrateModuleId, raw::ImportId)>>, |
53 | unresolved_imports: Vec<(CrateModuleId, raw::ImportId, raw::ImportData)>, | 55 | unresolved_imports: Vec<(CrateModuleId, raw::ImportId, raw::ImportData)>, |
54 | unexpanded_macros: Vec<(CrateModuleId, SourceItemId, Path)>, | 56 | unexpanded_macros: Vec<(CrateModuleId, AstId<ast::MacroCall>, Path)>, |
55 | global_macro_scope: FxHashMap<Name, MacroDefId>, | 57 | global_macro_scope: FxHashMap<Name, MacroDefId>, |
56 | } | 58 | } |
57 | 59 | ||
@@ -293,7 +295,7 @@ where | |||
293 | let mut macros = std::mem::replace(&mut self.unexpanded_macros, Vec::new()); | 295 | let mut macros = std::mem::replace(&mut self.unexpanded_macros, Vec::new()); |
294 | let mut resolved = Vec::new(); | 296 | let mut resolved = Vec::new(); |
295 | let mut res = ReachedFixedPoint::Yes; | 297 | let mut res = ReachedFixedPoint::Yes; |
296 | macros.retain(|(module_id, source_item_id, path)| { | 298 | macros.retain(|(module_id, ast_id, path)| { |
297 | if path.segments.len() != 2 { | 299 | if path.segments.len() != 2 { |
298 | return true; | 300 | return true; |
299 | } | 301 | } |
@@ -309,8 +311,7 @@ where | |||
309 | res = ReachedFixedPoint::No; | 311 | res = ReachedFixedPoint::No; |
310 | let def_map = self.db.crate_def_map(krate); | 312 | let def_map = self.db.crate_def_map(krate); |
311 | if let Some(macro_id) = def_map.public_macros.get(&path.segments[1].name).cloned() { | 313 | if let Some(macro_id) = def_map.public_macros.get(&path.segments[1].name).cloned() { |
312 | let call_id = | 314 | let call_id = MacroCallLoc { def: macro_id, ast_id: *ast_id }.id(self.db); |
313 | MacroCallLoc { def: macro_id, source_item_id: *source_item_id }.id(self.db); | ||
314 | resolved.push((*module_id, call_id)); | 315 | resolved.push((*module_id, call_id)); |
315 | } | 316 | } |
316 | false | 317 | false |
@@ -364,12 +365,9 @@ where | |||
364 | fn collect_module(&mut self, module: &raw::ModuleData) { | 365 | fn collect_module(&mut self, module: &raw::ModuleData) { |
365 | match module { | 366 | match module { |
366 | // inline module, just recurse | 367 | // inline module, just recurse |
367 | raw::ModuleData::Definition { name, items, source_item_id } => { | 368 | raw::ModuleData::Definition { name, items, ast_id } => { |
368 | let module_id = self.push_child_module( | 369 | let module_id = |
369 | name.clone(), | 370 | self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); |
370 | source_item_id.with_file_id(self.file_id), | ||
371 | None, | ||
372 | ); | ||
373 | ModCollector { | 371 | ModCollector { |
374 | def_collector: &mut *self.def_collector, | 372 | def_collector: &mut *self.def_collector, |
375 | module_id, | 373 | module_id, |
@@ -379,13 +377,12 @@ where | |||
379 | .collect(&*items); | 377 | .collect(&*items); |
380 | } | 378 | } |
381 | // out of line module, resovle, parse and recurse | 379 | // out of line module, resovle, parse and recurse |
382 | raw::ModuleData::Declaration { name, source_item_id } => { | 380 | raw::ModuleData::Declaration { name, ast_id } => { |
383 | let source_item_id = source_item_id.with_file_id(self.file_id); | 381 | let ast_id = ast_id.with_file_id(self.file_id); |
384 | let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none(); | 382 | let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none(); |
385 | match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) { | 383 | match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) { |
386 | Ok(file_id) => { | 384 | Ok(file_id) => { |
387 | let module_id = | 385 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); |
388 | self.push_child_module(name.clone(), source_item_id, Some(file_id)); | ||
389 | let raw_items = self.def_collector.db.raw_items(file_id.into()); | 386 | let raw_items = self.def_collector.db.raw_items(file_id.into()); |
390 | ModCollector { | 387 | ModCollector { |
391 | def_collector: &mut *self.def_collector, | 388 | def_collector: &mut *self.def_collector, |
@@ -398,7 +395,7 @@ where | |||
398 | Err(candidate) => self.def_collector.def_map.diagnostics.push( | 395 | Err(candidate) => self.def_collector.def_map.diagnostics.push( |
399 | DefDiagnostic::UnresolvedModule { | 396 | DefDiagnostic::UnresolvedModule { |
400 | module: self.module_id, | 397 | module: self.module_id, |
401 | declaration: source_item_id, | 398 | declaration: ast_id, |
402 | candidate, | 399 | candidate, |
403 | }, | 400 | }, |
404 | ), | 401 | ), |
@@ -410,7 +407,7 @@ where | |||
410 | fn push_child_module( | 407 | fn push_child_module( |
411 | &mut self, | 408 | &mut self, |
412 | name: Name, | 409 | name: Name, |
413 | declaration: SourceItemId, | 410 | declaration: AstId<ast::Module>, |
414 | definition: Option<FileId>, | 411 | definition: Option<FileId>, |
415 | ) -> CrateModuleId { | 412 | ) -> CrateModuleId { |
416 | let modules = &mut self.def_collector.def_map.modules; | 413 | let modules = &mut self.def_collector.def_map.modules; |
@@ -432,23 +429,24 @@ where | |||
432 | fn define_def(&mut self, def: &raw::DefData) { | 429 | fn define_def(&mut self, def: &raw::DefData) { |
433 | let module = Module { krate: self.def_collector.def_map.krate, module_id: self.module_id }; | 430 | let module = Module { krate: self.def_collector.def_map.krate, module_id: self.module_id }; |
434 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id.into()); | 431 | let ctx = LocationCtx::new(self.def_collector.db, module, self.file_id.into()); |
435 | macro_rules! id { | 432 | |
436 | () => { | 433 | macro_rules! def { |
437 | AstItemDef::from_source_item_id_unchecked(ctx, def.source_item_id) | 434 | ($kind:ident, $ast_id:ident) => { |
435 | $kind { id: AstItemDef::from_ast_id(ctx, $ast_id) }.into() | ||
438 | }; | 436 | }; |
439 | } | 437 | } |
440 | let name = def.name.clone(); | 438 | let name = def.name.clone(); |
441 | let def: PerNs<ModuleDef> = match def.kind { | 439 | let def: PerNs<ModuleDef> = match def.kind { |
442 | raw::DefKind::Function => PerNs::values(Function { id: id!() }.into()), | 440 | raw::DefKind::Function(ast_id) => PerNs::values(def!(Function, ast_id)), |
443 | raw::DefKind::Struct => { | 441 | raw::DefKind::Struct(ast_id) => { |
444 | let s = Struct { id: id!() }.into(); | 442 | let s = def!(Struct, ast_id); |
445 | PerNs::both(s, s) | 443 | PerNs::both(s, s) |
446 | } | 444 | } |
447 | raw::DefKind::Enum => PerNs::types(Enum { id: id!() }.into()), | 445 | raw::DefKind::Enum(ast_id) => PerNs::types(def!(Enum, ast_id)), |
448 | raw::DefKind::Const => PerNs::values(Const { id: id!() }.into()), | 446 | raw::DefKind::Const(ast_id) => PerNs::values(def!(Const, ast_id)), |
449 | raw::DefKind::Static => PerNs::values(Static { id: id!() }.into()), | 447 | raw::DefKind::Static(ast_id) => PerNs::values(def!(Static, ast_id)), |
450 | raw::DefKind::Trait => PerNs::types(Trait { id: id!() }.into()), | 448 | raw::DefKind::Trait(ast_id) => PerNs::types(def!(Trait, ast_id)), |
451 | raw::DefKind::TypeAlias => PerNs::types(TypeAlias { id: id!() }.into()), | 449 | raw::DefKind::TypeAlias(ast_id) => PerNs::types(def!(TypeAlias, ast_id)), |
452 | }; | 450 | }; |
453 | let resolution = Resolution { def, import: None }; | 451 | let resolution = Resolution { def, import: None }; |
454 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) | 452 | self.def_collector.update(self.module_id, None, &[(name, resolution)]) |
@@ -458,34 +456,27 @@ where | |||
458 | // Case 1: macro rules, define a macro in crate-global mutable scope | 456 | // Case 1: macro rules, define a macro in crate-global mutable scope |
459 | if is_macro_rules(&mac.path) { | 457 | if is_macro_rules(&mac.path) { |
460 | if let Some(name) = &mac.name { | 458 | if let Some(name) = &mac.name { |
461 | let macro_id = MacroDefId::MacroByExample { | 459 | let macro_id = MacroDefId(mac.ast_id.with_file_id(self.file_id)); |
462 | source_item_id: mac.source_item_id.with_file_id(self.file_id), | ||
463 | }; | ||
464 | self.def_collector.define_macro(name.clone(), macro_id, mac.export) | 460 | self.def_collector.define_macro(name.clone(), macro_id, mac.export) |
465 | } | 461 | } |
466 | return; | 462 | return; |
467 | } | 463 | } |
468 | 464 | ||
469 | let source_item_id = SourceItemId { file_id: self.file_id, item_id: mac.source_item_id }; | 465 | let ast_id = mac.ast_id.with_file_id(self.file_id); |
470 | 466 | ||
471 | // Case 2: try to expand macro_rules from this crate, triggering | 467 | // Case 2: try to expand macro_rules from this crate, triggering |
472 | // recursive item collection. | 468 | // recursive item collection. |
473 | if let Some(¯o_id) = | 469 | if let Some(¯o_id) = |
474 | mac.path.as_ident().and_then(|name| self.def_collector.global_macro_scope.get(name)) | 470 | mac.path.as_ident().and_then(|name| self.def_collector.global_macro_scope.get(name)) |
475 | { | 471 | { |
476 | let macro_call_id = | 472 | let macro_call_id = MacroCallLoc { def: macro_id, ast_id }.id(self.def_collector.db); |
477 | MacroCallLoc { def: macro_id, source_item_id }.id(self.def_collector.db); | ||
478 | 473 | ||
479 | self.def_collector.collect_macro_expansion(self.module_id, macro_call_id); | 474 | self.def_collector.collect_macro_expansion(self.module_id, macro_call_id); |
480 | return; | 475 | return; |
481 | } | 476 | } |
482 | 477 | ||
483 | // Case 3: path to a macro from another crate, expand during name resolution | 478 | // Case 3: path to a macro from another crate, expand during name resolution |
484 | self.def_collector.unexpanded_macros.push(( | 479 | self.def_collector.unexpanded_macros.push((self.module_id, ast_id, mac.path.clone())) |
485 | self.module_id, | ||
486 | source_item_id, | ||
487 | mac.path.clone(), | ||
488 | )) | ||
489 | } | 480 | } |
490 | } | 481 | } |
491 | 482 | ||
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index f32004601..0936229ac 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -12,7 +12,7 @@ use ra_syntax::{ | |||
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, | 14 | DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, |
15 | SourceFileItemId, SourceFileItems, | 15 | AstIdMap, FileAstId, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | /// `RawItems` is a set of top-level items in a file (except for impls). | 18 | /// `RawItems` is a set of top-level items in a file (except for impls). |
@@ -60,7 +60,7 @@ impl RawItems { | |||
60 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>) { | 60 | ) -> (Arc<RawItems>, Arc<ImportSourceMap>) { |
61 | let mut collector = RawItemsCollector { | 61 | let mut collector = RawItemsCollector { |
62 | raw_items: RawItems::default(), | 62 | raw_items: RawItems::default(), |
63 | source_file_items: db.file_items(file_id.into()), | 63 | source_ast_id_map: db.ast_id_map(file_id.into()), |
64 | source_map: ImportSourceMap::default(), | 64 | source_map: ImportSourceMap::default(), |
65 | }; | 65 | }; |
66 | let source_file = db.hir_parse(file_id); | 66 | let source_file = db.hir_parse(file_id); |
@@ -115,8 +115,8 @@ impl_arena_id!(Module); | |||
115 | 115 | ||
116 | #[derive(Debug, PartialEq, Eq)] | 116 | #[derive(Debug, PartialEq, Eq)] |
117 | pub(super) enum ModuleData { | 117 | pub(super) enum ModuleData { |
118 | Declaration { name: Name, source_item_id: SourceFileItemId }, | 118 | Declaration { name: Name, ast_id: FileAstId<ast::Module> }, |
119 | Definition { name: Name, source_item_id: SourceFileItemId, items: Vec<RawItem> }, | 119 | Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> }, |
120 | } | 120 | } |
121 | 121 | ||
122 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 122 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -138,20 +138,19 @@ impl_arena_id!(Def); | |||
138 | 138 | ||
139 | #[derive(Debug, PartialEq, Eq)] | 139 | #[derive(Debug, PartialEq, Eq)] |
140 | pub(super) struct DefData { | 140 | pub(super) struct DefData { |
141 | pub(super) source_item_id: SourceFileItemId, | ||
142 | pub(super) name: Name, | 141 | pub(super) name: Name, |
143 | pub(super) kind: DefKind, | 142 | pub(super) kind: DefKind, |
144 | } | 143 | } |
145 | 144 | ||
146 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 145 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
147 | pub(super) enum DefKind { | 146 | pub(super) enum DefKind { |
148 | Function, | 147 | Function(FileAstId<ast::FnDef>), |
149 | Struct, | 148 | Struct(FileAstId<ast::StructDef>), |
150 | Enum, | 149 | Enum(FileAstId<ast::EnumDef>), |
151 | Const, | 150 | Const(FileAstId<ast::ConstDef>), |
152 | Static, | 151 | Static(FileAstId<ast::StaticDef>), |
153 | Trait, | 152 | Trait(FileAstId<ast::TraitDef>), |
154 | TypeAlias, | 153 | TypeAlias(FileAstId<ast::TypeAliasDef>), |
155 | } | 154 | } |
156 | 155 | ||
157 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 156 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -160,7 +159,7 @@ impl_arena_id!(Macro); | |||
160 | 159 | ||
161 | #[derive(Debug, PartialEq, Eq)] | 160 | #[derive(Debug, PartialEq, Eq)] |
162 | pub(super) struct MacroData { | 161 | pub(super) struct MacroData { |
163 | pub(super) source_item_id: SourceFileItemId, | 162 | pub(super) ast_id: FileAstId<ast::MacroCall>, |
164 | pub(super) path: Path, | 163 | pub(super) path: Path, |
165 | pub(super) name: Option<Name>, | 164 | pub(super) name: Option<Name>, |
166 | pub(super) export: bool, | 165 | pub(super) export: bool, |
@@ -168,7 +167,7 @@ pub(super) struct MacroData { | |||
168 | 167 | ||
169 | struct RawItemsCollector { | 168 | struct RawItemsCollector { |
170 | raw_items: RawItems, | 169 | raw_items: RawItems, |
171 | source_file_items: Arc<SourceFileItems>, | 170 | source_ast_id_map: Arc<AstIdMap>, |
172 | source_map: ImportSourceMap, | 171 | source_map: ImportSourceMap, |
173 | } | 172 | } |
174 | 173 | ||
@@ -200,18 +199,31 @@ impl RawItemsCollector { | |||
200 | // impls don't participate in name resolution | 199 | // impls don't participate in name resolution |
201 | return; | 200 | return; |
202 | } | 201 | } |
203 | ast::ModuleItemKind::StructDef(it) => (DefKind::Struct, it.name()), | 202 | ast::ModuleItemKind::StructDef(it) => { |
204 | ast::ModuleItemKind::EnumDef(it) => (DefKind::Enum, it.name()), | 203 | (DefKind::Struct(self.source_ast_id_map.ast_id(it)), it.name()) |
205 | ast::ModuleItemKind::FnDef(it) => (DefKind::Function, it.name()), | 204 | } |
206 | ast::ModuleItemKind::TraitDef(it) => (DefKind::Trait, it.name()), | 205 | ast::ModuleItemKind::EnumDef(it) => { |
207 | ast::ModuleItemKind::TypeAliasDef(it) => (DefKind::TypeAlias, it.name()), | 206 | (DefKind::Enum(self.source_ast_id_map.ast_id(it)), it.name()) |
208 | ast::ModuleItemKind::ConstDef(it) => (DefKind::Const, it.name()), | 207 | } |
209 | ast::ModuleItemKind::StaticDef(it) => (DefKind::Static, it.name()), | 208 | ast::ModuleItemKind::FnDef(it) => { |
209 | (DefKind::Function(self.source_ast_id_map.ast_id(it)), it.name()) | ||
210 | } | ||
211 | ast::ModuleItemKind::TraitDef(it) => { | ||
212 | (DefKind::Trait(self.source_ast_id_map.ast_id(it)), it.name()) | ||
213 | } | ||
214 | ast::ModuleItemKind::TypeAliasDef(it) => { | ||
215 | (DefKind::TypeAlias(self.source_ast_id_map.ast_id(it)), it.name()) | ||
216 | } | ||
217 | ast::ModuleItemKind::ConstDef(it) => { | ||
218 | (DefKind::Const(self.source_ast_id_map.ast_id(it)), it.name()) | ||
219 | } | ||
220 | ast::ModuleItemKind::StaticDef(it) => { | ||
221 | (DefKind::Static(self.source_ast_id_map.ast_id(it)), it.name()) | ||
222 | } | ||
210 | }; | 223 | }; |
211 | if let Some(name) = name { | 224 | if let Some(name) = name { |
212 | let name = name.as_name(); | 225 | let name = name.as_name(); |
213 | let source_item_id = self.source_file_items.id_of_unchecked(item.syntax()); | 226 | let def = self.raw_items.defs.alloc(DefData { name, kind }); |
214 | let def = self.raw_items.defs.alloc(DefData { name, kind, source_item_id }); | ||
215 | self.push_item(current_module, RawItem::Def(def)) | 227 | self.push_item(current_module, RawItem::Def(def)) |
216 | } | 228 | } |
217 | } | 229 | } |
@@ -221,10 +233,9 @@ impl RawItemsCollector { | |||
221 | Some(it) => it.as_name(), | 233 | Some(it) => it.as_name(), |
222 | None => return, | 234 | None => return, |
223 | }; | 235 | }; |
224 | let source_item_id = self.source_file_items.id_of_unchecked(module.syntax()); | 236 | let ast_id = self.source_ast_id_map.ast_id(module); |
225 | if module.has_semi() { | 237 | if module.has_semi() { |
226 | let item = | 238 | let item = self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id }); |
227 | self.raw_items.modules.alloc(ModuleData::Declaration { name, source_item_id }); | ||
228 | self.push_item(current_module, RawItem::Module(item)); | 239 | self.push_item(current_module, RawItem::Module(item)); |
229 | return; | 240 | return; |
230 | } | 241 | } |
@@ -232,7 +243,7 @@ impl RawItemsCollector { | |||
232 | if let Some(item_list) = module.item_list() { | 243 | if let Some(item_list) = module.item_list() { |
233 | let item = self.raw_items.modules.alloc(ModuleData::Definition { | 244 | let item = self.raw_items.modules.alloc(ModuleData::Definition { |
234 | name, | 245 | name, |
235 | source_item_id, | 246 | ast_id, |
236 | items: Vec::new(), | 247 | items: Vec::new(), |
237 | }); | 248 | }); |
238 | self.process_module(Some(item), item_list); | 249 | self.process_module(Some(item), item_list); |
@@ -286,9 +297,9 @@ impl RawItemsCollector { | |||
286 | }; | 297 | }; |
287 | 298 | ||
288 | let name = m.name().map(|it| it.as_name()); | 299 | let name = m.name().map(|it| it.as_name()); |
289 | let source_item_id = self.source_file_items.id_of_unchecked(m.syntax()); | 300 | let ast_id = self.source_ast_id_map.ast_id(m); |
290 | let export = m.has_atom_attr("macro_export"); | 301 | let export = m.has_atom_attr("macro_export"); |
291 | let m = self.raw_items.macros.alloc(MacroData { source_item_id, path, name, export }); | 302 | let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export }); |
292 | self.push_item(current_module, RawItem::Macro(m)); | 303 | self.push_item(current_module, RawItem::Macro(m)); |
293 | } | 304 | } |
294 | 305 | ||