mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Merge #6901
6901: Temp fixes panic caused by no ast for proc-macro r=maklad a=edwin0cheng There are some panic when hover/goto definition for proc-macro. It is because in current design, we don't have `ast-node` for proc-macro and then it trigger [this](479d1f7eec/crates/hir/src/has_source.rs (L116)
) line to panic. This PR is a temp fix for all of these similar tobd4c352831/crates/completion/src/render/macro_.rs (L42)
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
f4929fa9cc
4 changed files with 22 additions and 1 deletions
|
@ -155,7 +155,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)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue