mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
HasSource::source_old -> HasSource::source for places where proc-macros were special cased
In #6901 some special case handling for proc-macros was introduced to prevent panicing as they have no AST. Now the new HasSource::source method is used that returns an option. Generally this was a pretty trivial change, the only thing of much interest is that `hir::MacroDef` now implements `TryToNav` not `ToNav` as this allows us to handle `HasSource::source` now returning an option.
This commit is contained in:
parent
ea4708c444
commit
14d0db0759
4 changed files with 11 additions and 42 deletions
|
@ -983,14 +983,7 @@ 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;
|
||||
}
|
||||
#[allow(deprecated)]
|
||||
self.source_old(db).value.name().map(|it| it.as_name())
|
||||
self.source(db)?.value.name().map(|it| it.as_name())
|
||||
}
|
||||
|
||||
/// Indicate it is a proc-macro
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue