fn expand(
&self,
subtree: &Subtree,
- _attr: Option<&Subtree>,
+ attr: Option<&Subtree>,
) -> Result<Subtree, tt::ExpansionError> {
- self.process.custom_derive(&self.dylib_path, subtree, &self.name)
+ let task = ExpansionTask {
+ macro_body: subtree.clone(),
+ macro_name: self.name.to_string(),
+ attributes: attr.cloned(),
+ lib: self.dylib_path.to_path_buf(),
+ };
+
+ let result: ExpansionResult = self.process.send_task(msg::Request::ExpansionMacro(task))?;
+ Ok(result.expansion)
}
}
};
use crossbeam_channel::{bounded, Receiver, Sender};
-use tt::Subtree;
use crate::{
msg::{ErrorCode, Message, Request, Response, ResponseError},
- rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind},
+ rpc::{ListMacrosResult, ListMacrosTask, ProcMacroKind},
};
#[derive(Debug, Default)]
Ok(result.macros)
}
- pub(crate) fn custom_derive(
- &self,
- dylib_path: &Path,
- subtree: &Subtree,
- derive_name: &str,
- ) -> Result<Subtree, tt::ExpansionError> {
- let task = ExpansionTask {
- macro_body: subtree.clone(),
- macro_name: derive_name.to_string(),
- attributes: None,
- lib: dylib_path.to_path_buf(),
- };
-
- let result: ExpansionResult = self.send_task(Request::ExpansionMacro(task))?;
- Ok(result.expansion)
- }
-
pub(crate) fn send_task<R>(&self, req: Request) -> Result<R, tt::ExpansionError>
where
R: TryFrom<Response, Error = &'static str>,