diff options
author | Edwin Cheng <[email protected]> | 2020-12-18 02:26:17 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-12-18 02:26:17 +0000 |
commit | 60a3785ac27d7361617977bd53e11f2859e97c7c (patch) | |
tree | b79241db7008f95204b42e45a41dcbc4d07bda99 /crates | |
parent | c1c36acb025880c742c65f436a61fd87fc627eb0 (diff) |
Temp fixes panic caused by no ast for proc-macro
Diffstat (limited to 'crates')
-rw-r--r-- | crates/completion/src/render/macro_.rs | 1 | ||||
-rw-r--r-- | crates/hir/src/code_model.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 10 | ||||
-rw-r--r-- | crates/ide/src/hover.rs | 6 |
4 files changed, 22 insertions, 1 deletions
diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index 6cfbd6c9b..dac79592f 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs | |||
@@ -41,6 +41,7 @@ impl<'a> MacroRender<'a> { | |||
41 | fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> { | 41 | fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> { |
42 | // FIXME: Currently proc-macro do not have ast-node, | 42 | // FIXME: Currently proc-macro do not have ast-node, |
43 | // such that it does not have source | 43 | // such that it does not have source |
44 | // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913 | ||
44 | if self.macro_.is_proc_macro() { | 45 | if self.macro_.is_proc_macro() { |
45 | return None; | 46 | return None; |
46 | } | 47 | } |
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 42dc35b76..7ffa79996 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -977,6 +977,12 @@ impl MacroDef { | |||
977 | 977 | ||
978 | /// XXX: this parses the file | 978 | /// XXX: this parses the file |
979 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { | 979 | pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { |
980 | // FIXME: Currently proc-macro do not have ast-node, | ||
981 | // such that it does not have source | ||
982 | // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913 | ||
983 | if self.is_proc_macro() { | ||
984 | return None; | ||
985 | } | ||
980 | self.source(db).value.name().map(|it| it.as_name()) | 986 | self.source(db).value.name().map(|it| it.as_name()) |
981 | } | 987 | } |
982 | 988 | ||
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 234f80a3a..73fc73619 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -176,7 +176,15 @@ impl ToNav for FileSymbol { | |||
176 | impl TryToNav for Definition { | 176 | impl TryToNav for Definition { |
177 | fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { | 177 | fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { |
178 | match self { | 178 | match self { |
179 | Definition::Macro(it) => Some(it.to_nav(db)), | 179 | Definition::Macro(it) => { |
180 | // FIXME: Currently proc-macro do not have ast-node, | ||
181 | // such that it does not have source | ||
182 | // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913 | ||
183 | if it.is_proc_macro() { | ||
184 | return None; | ||
185 | } | ||
186 | Some(it.to_nav(db)) | ||
187 | } | ||
180 | Definition::Field(it) => Some(it.to_nav(db)), | 188 | Definition::Field(it) => Some(it.to_nav(db)), |
181 | Definition::ModuleDef(it) => it.try_to_nav(db), | 189 | Definition::ModuleDef(it) => it.try_to_nav(db), |
182 | Definition::SelfType(it) => Some(it.to_nav(db)), | 190 | Definition::SelfType(it) => Some(it.to_nav(db)), |
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index ab017d2ad..c03dd74e4 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -324,6 +324,12 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> { | |||
324 | let mod_path = definition_mod_path(db, &def); | 324 | let mod_path = definition_mod_path(db, &def); |
325 | return match def { | 325 | return match def { |
326 | Definition::Macro(it) => { | 326 | Definition::Macro(it) => { |
327 | // FIXME: Currently proc-macro do not have ast-node, | ||
328 | // such that it does not have source | ||
329 | // more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913 | ||
330 | if it.is_proc_macro() { | ||
331 | return None; | ||
332 | } | ||
327 | let label = macro_label(&it.source(db).value); | 333 | let label = macro_label(&it.source(db).value); |
328 | from_def_source_labeled(db, it, Some(label), mod_path) | 334 | from_def_source_labeled(db, it, Some(label), mod_path) |
329 | } | 335 | } |