diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-12 11:33:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-12 11:33:31 +0000 |
commit | 8bb2a50ce6adda4d3d8dfb66cd67d302ec108d45 (patch) | |
tree | f856e09f543a391916907fd9a19257924eb2bfaf /crates/ra_hir_expand | |
parent | 21be386db8e8019d25c2529313d0371f91a15cb3 (diff) | |
parent | db5f73d261413f03e4e3a4a374f8306fe8ae5578 (diff) |
Merge #2807
2807: Use attr location for builtin derive in goto-implementation r=matklad a=edwin0cheng
This PR is use attribute location for builtin derive in `ImplBlock`'s NavigationTarget such that the goto-implementation will goto to a correct position.
Related to #2531
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand')
-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)] |