mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-08 16:07:43 +00:00
Temp fixes panic caused by no ast for proc-macro
This commit is contained in:
parent
c1c36acb02
commit
60a3785ac2
@ -41,6 +41,7 @@ impl<'a> MacroRender<'a> {
|
||||
fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
|
||||
// FIXME: Currently proc-macro do not have ast-node,
|
||||
// such that it does not have source
|
||||
// more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
|
||||
if self.macro_.is_proc_macro() {
|
||||
return None;
|
||||
}
|
||||
|
@ -977,6 +977,12 @@ impl MacroDef {
|
||||
|
||||
/// XXX: this parses the file
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||
// FIXME: Currently proc-macro do not have ast-node,
|
||||
// such that it does not have source
|
||||
// more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
|
||||
if self.is_proc_macro() {
|
||||
return None;
|
||||
}
|
||||
self.source(db).value.name().map(|it| it.as_name())
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,15 @@ impl ToNav for FileSymbol {
|
||||
impl TryToNav for Definition {
|
||||
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
|
||||
match self {
|
||||
Definition::Macro(it) => Some(it.to_nav(db)),
|
||||
Definition::Macro(it) => {
|
||||
// FIXME: Currently proc-macro do not have ast-node,
|
||||
// such that it does not have source
|
||||
// more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
|
||||
if it.is_proc_macro() {
|
||||
return None;
|
||||
}
|
||||
Some(it.to_nav(db))
|
||||
}
|
||||
Definition::Field(it) => Some(it.to_nav(db)),
|
||||
Definition::ModuleDef(it) => it.try_to_nav(db),
|
||||
Definition::SelfType(it) => Some(it.to_nav(db)),
|
||||
|
@ -324,6 +324,12 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
|
||||
let mod_path = definition_mod_path(db, &def);
|
||||
return match def {
|
||||
Definition::Macro(it) => {
|
||||
// FIXME: Currently proc-macro do not have ast-node,
|
||||
// such that it does not have source
|
||||
// more discussion: https://github.com/rust-analyzer/rust-analyzer/issues/6913
|
||||
if it.is_proc_macro() {
|
||||
return None;
|
||||
}
|
||||
let label = macro_label(&it.source(db).value);
|
||||
from_def_source_labeled(db, it, Some(label), mod_path)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user