Skip to content

Commit 60a3785

Browse files
committed
Temp fixes panic caused by no ast for proc-macro
1 parent c1c36ac commit 60a3785

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

crates/completion/src/render/macro_.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl<'a> MacroRender<'a> {
4141
fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
4242
// FIXME: Currently proc-macro do not have ast-node,
4343
// such that it does not have source
44+
// more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
4445
if self.macro_.is_proc_macro() {
4546
return None;
4647
}

crates/hir/src/code_model.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,12 @@ impl MacroDef {
977977

978978
/// XXX: this parses the file
979979
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+
}
980986
self.source(db).value.name().map(|it| it.as_name())
981987
}
982988

crates/ide/src/display/navigation_target.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,15 @@ impl ToNav for FileSymbol {
176176
impl TryToNav for Definition {
177177
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
178178
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+
}
180188
Definition::Field(it) => Some(it.to_nav(db)),
181189
Definition::ModuleDef(it) => it.try_to_nav(db),
182190
Definition::SelfType(it) => Some(it.to_nav(db)),

crates/ide/src/hover.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
324324
let mod_path = definition_mod_path(db, &def);
325325
return match def {
326326
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+
}
327333
let label = macro_label(&it.source(db).value);
328334
from_def_source_labeled(db, it, Some(label), mod_path)
329335
}

0 commit comments

Comments
 (0)