mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Add basic custom derive lowering
This commit is contained in:
parent
e2dd17f75b
commit
34dc8d25c1
11 changed files with 152 additions and 28 deletions
32
crates/ra_hir_expand/src/proc_macro.rs
Normal file
32
crates/ra_hir_expand/src/proc_macro.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
//! Proc Macro Expander stub
|
||||
|
||||
use crate::{db::AstDatabase, LazyMacroId, MacroCallKind, MacroCallLoc};
|
||||
use ra_db::CrateId;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||
pub struct ProcMacroExpander {
|
||||
krate: CrateId,
|
||||
}
|
||||
|
||||
impl ProcMacroExpander {
|
||||
pub fn new(krate: CrateId) -> ProcMacroExpander {
|
||||
ProcMacroExpander { krate }
|
||||
}
|
||||
|
||||
pub fn expand(
|
||||
&self,
|
||||
db: &dyn AstDatabase,
|
||||
id: LazyMacroId,
|
||||
_tt: &tt::Subtree,
|
||||
) -> Result<tt::Subtree, mbe::ExpandError> {
|
||||
let loc: MacroCallLoc = db.lookup_intern_macro(id);
|
||||
let name = match loc.kind {
|
||||
MacroCallKind::FnLike(_) => return Err(mbe::ExpandError::ConversionError),
|
||||
MacroCallKind::Attr(_, name) => name,
|
||||
};
|
||||
|
||||
dbg!(name);
|
||||
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue