diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-26 18:34:15 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-26 18:34:15 +0000 |
commit | 3206b83a70b4e9140a5f0d9d8454abb7864b543a (patch) | |
tree | 81c441643aebd07039ca08c80c905d77a28eb800 /crates/ra_hir_expand/src | |
parent | 141fca60061d85494fcb719a4c8237eaf6c7c134 (diff) | |
parent | 447268ceac497432822e8cf28525a6784f392020 (diff) |
Merge #2418
2418: Hide MacroCallLoc outside hir_expand r=matklad a=edwin0cheng
This PR refactor `MacroCallLoc` such that it be hided to become implementation details of hir_expand.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 4f3ccf1d0..b6a739cda 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -135,6 +135,16 @@ pub struct MacroDefId { | |||
135 | pub kind: MacroDefKind, | 135 | pub kind: MacroDefKind, |
136 | } | 136 | } |
137 | 137 | ||
138 | impl MacroDefId { | ||
139 | pub fn as_call_id( | ||
140 | self, | ||
141 | db: &dyn db::AstDatabase, | ||
142 | ast_id: AstId<ast::MacroCall>, | ||
143 | ) -> MacroCallId { | ||
144 | db.intern_macro(MacroCallLoc { def: self, ast_id }) | ||
145 | } | ||
146 | } | ||
147 | |||
138 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 148 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
139 | pub enum MacroDefKind { | 149 | pub enum MacroDefKind { |
140 | Declarative, | 150 | Declarative, |
@@ -143,8 +153,8 @@ pub enum MacroDefKind { | |||
143 | 153 | ||
144 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 154 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
145 | pub struct MacroCallLoc { | 155 | pub struct MacroCallLoc { |
146 | pub def: MacroDefId, | 156 | pub(crate) def: MacroDefId, |
147 | pub ast_id: AstId<ast::MacroCall>, | 157 | pub(crate) ast_id: AstId<ast::MacroCall>, |
148 | } | 158 | } |
149 | 159 | ||
150 | impl MacroCallId { | 160 | impl MacroCallId { |