diff options
author | Jonas Schievink <[email protected]> | 2020-12-15 14:37:37 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-12-15 14:37:37 +0000 |
commit | c1cb5953820f26d4d0a614650bc8c50cbc5a3ce6 (patch) | |
tree | 01ba67d97ce6f261154df59b268fe924af9add2a /crates/hir/src | |
parent | 39aae835fd70d06092c1be1add6eef3984439529 (diff) |
Move to upstream `macro_rules!` model
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/has_source.rs | 4 | ||||
-rw-r--r-- | crates/hir/src/semantics.rs | 2 | ||||
-rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 5 |
3 files changed, 7 insertions, 4 deletions
diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs index 1e64a1614..107ad0690 100644 --- a/crates/hir/src/has_source.rs +++ b/crates/hir/src/has_source.rs | |||
@@ -110,8 +110,8 @@ impl HasSource for TypeAlias { | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | impl HasSource for MacroDef { | 112 | impl HasSource for MacroDef { |
113 | type Ast = ast::MacroCall; | 113 | type Ast = ast::MacroRules; |
114 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::MacroCall> { | 114 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::MacroRules> { |
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()), |
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index e4fc21ced..5959ac4ca 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -723,7 +723,7 @@ to_def_impls![ | |||
723 | (crate::EnumVariant, ast::Variant, enum_variant_to_def), | 723 | (crate::EnumVariant, ast::Variant, enum_variant_to_def), |
724 | (crate::TypeParam, ast::TypeParam, type_param_to_def), | 724 | (crate::TypeParam, ast::TypeParam, type_param_to_def), |
725 | (crate::LifetimeParam, ast::LifetimeParam, lifetime_param_to_def), | 725 | (crate::LifetimeParam, ast::LifetimeParam, lifetime_param_to_def), |
726 | (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros | 726 | (crate::MacroDef, ast::MacroRules, macro_rules_to_def), |
727 | (crate::Local, ast::IdentPat, bind_pat_to_def), | 727 | (crate::Local, ast::IdentPat, bind_pat_to_def), |
728 | ]; | 728 | ]; |
729 | 729 | ||
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index badcf0ae8..a333d7aea 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs | |||
@@ -149,7 +149,10 @@ impl SourceToDefCtx<'_, '_> { | |||
149 | } | 149 | } |
150 | 150 | ||
151 | // FIXME: use DynMap as well? | 151 | // FIXME: use DynMap as well? |
152 | pub(super) fn macro_call_to_def(&mut self, src: InFile<ast::MacroCall>) -> Option<MacroDefId> { | 152 | pub(super) fn macro_rules_to_def( |
153 | &mut self, | ||
154 | src: InFile<ast::MacroRules>, | ||
155 | ) -> Option<MacroDefId> { | ||
153 | let kind = MacroDefKind::Declarative; | 156 | let kind = MacroDefKind::Declarative; |
154 | let file_id = src.file_id.original_file(self.db.upcast()); | 157 | let file_id = src.file_id.original_file(self.db.upcast()); |
155 | let krate = self.file_to_def(file_id)?.krate; | 158 | let krate = self.file_to_def(file_id)?.krate; |