diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-18 14:38:04 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-18 14:38:04 +0000 |
commit | 3ab9b39dd47d99ffd97f485c27f38b8944e12a3e (patch) | |
tree | 308ffffd0b61517f13aedad9621430f4c41014e3 /crates/hir/src/semantics | |
parent | 816bc7389516dda1eb4821f2ac4d5993cd5611dd (diff) | |
parent | b84efbaacfc980ba167edc145aa7ca5d738448ff (diff) |
Merge #8087
8087: Make MacroDefId's `AstId` mandatory when possible r=jonas-schievink a=jonas-schievink
This makes it clearer (in the type definition) which macros have or don't have an `AstId`
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir/src/semantics')
-rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index c6ad5ecb5..762809fcd 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs | |||
@@ -195,12 +195,12 @@ impl SourceToDefCtx<'_, '_> { | |||
195 | &mut self, | 195 | &mut self, |
196 | src: InFile<ast::MacroRules>, | 196 | src: InFile<ast::MacroRules>, |
197 | ) -> Option<MacroDefId> { | 197 | ) -> Option<MacroDefId> { |
198 | let kind = MacroDefKind::Declarative; | 198 | let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); |
199 | let ast_id = AstId::new(src.file_id, file_ast_id.upcast()); | ||
200 | let kind = MacroDefKind::Declarative(ast_id); | ||
199 | let file_id = src.file_id.original_file(self.db.upcast()); | 201 | let file_id = src.file_id.original_file(self.db.upcast()); |
200 | let krate = self.file_to_def(file_id).get(0).copied()?.krate(); | 202 | let krate = self.file_to_def(file_id).get(0).copied()?.krate(); |
201 | let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); | 203 | Some(MacroDefId { krate, kind, local_inner: false }) |
202 | let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast())); | ||
203 | Some(MacroDefId { krate, ast_id, kind, local_inner: false }) | ||
204 | } | 204 | } |
205 | 205 | ||
206 | pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> { | 206 | pub(super) fn find_container(&mut self, src: InFile<&SyntaxNode>) -> Option<ChildContainer> { |