aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-01-12 10:08:53 +0000
committerEdwin Cheng <[email protected]>2020-01-12 10:08:53 +0000
commitd7be1a437239770552199028259639e6dfa8a664 (patch)
tree3b1d063a8f9b8786924577d6ebc16dd9aa682d51 /crates/ra_hir_expand
parent86d2af9f7b3f6af2ea9e4eca2584aa501b60aa14 (diff)
Use attr location for builtin macro goto-imp
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index 51c5f9623..7cf3b59a7 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -112,6 +112,21 @@ impl HirFileId {
112 } 112 }
113 } 113 }
114 } 114 }
115
116 /// Indicate it is macro file generated for builtin derive
117 pub fn is_builtin_derive(&self, db: &dyn db::AstDatabase) -> Option<InFile<ast::ModuleItem>> {
118 match self.0 {
119 HirFileIdRepr::FileId(_) => None,
120 HirFileIdRepr::MacroFile(macro_file) => {
121 let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id);
122 let item = match loc.def.kind {
123 MacroDefKind::BuiltInDerive(_) => loc.kind.node(db),
124 _ => return None,
125 };
126 Some(item.with_value(ast::ModuleItem::cast(item.value.clone())?))
127 }
128 }
129 }
115} 130}
116 131
117#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 132#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]