diff options
Diffstat (limited to 'crates/ra_hir_expand/src/lib.rs')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 15 |
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)] |