mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Return Either
from MacroDefId::ast_id
This commit is contained in:
parent
0392e63c95
commit
93aeb16eb2
4 changed files with 15 additions and 18 deletions
|
@ -6,7 +6,7 @@ use hir_def::{
|
|||
src::{HasChildSource, HasSource as _},
|
||||
Lookup, VariantId,
|
||||
};
|
||||
use hir_expand::{InFile, MacroDefKind};
|
||||
use hir_expand::InFile;
|
||||
use syntax::ast;
|
||||
|
||||
use crate::{
|
||||
|
@ -113,15 +113,10 @@ impl HasSource for TypeAlias {
|
|||
impl HasSource for MacroDef {
|
||||
type Ast = Either<ast::Macro, ast::Fn>;
|
||||
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||
Some(match &self.id.kind {
|
||||
MacroDefKind::Declarative(id)
|
||||
| MacroDefKind::BuiltIn(_, id)
|
||||
| MacroDefKind::BuiltInDerive(_, id)
|
||||
| MacroDefKind::BuiltInEager(_, id) => {
|
||||
id.with_value(Either::Left(id.to_node(db.upcast())))
|
||||
}
|
||||
MacroDefKind::ProcMacro(_, id) => id.map(|_| Either::Right(id.to_node(db.upcast()))),
|
||||
})
|
||||
Some(self.id.ast_id().either(
|
||||
|id| id.with_value(Either::Left(id.to_node(db.upcast()))),
|
||||
|id| id.with_value(Either::Right(id.to_node(db.upcast()))),
|
||||
))
|
||||
}
|
||||
}
|
||||
impl HasSource for Impl {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue