From 798968e1e3a7d9eafa0c27c857571cdc347c34a7 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 11 Dec 2020 14:24:02 +0100 Subject: Move TokenExpander to base_db and rename it It's only used to break the dependency to proc_macro_api --- crates/base_db/src/input.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'crates/base_db/src/input.rs') diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index cda5e57dc..a693e7f80 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -6,12 +6,12 @@ //! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how //! actual IO is done and lowered to input. -use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc}; +use std::{fmt, iter::FromIterator, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc}; use cfg::CfgOptions; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::SmolStr; -use tt::TokenExpander; +use tt::{ExpansionError, Subtree}; use vfs::{file_set::FileSet, FileId, VfsPath}; /// Files are grouped into source roots. A source root is a directory on the @@ -150,11 +150,16 @@ pub enum ProcMacroKind { Attr, } +pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe { + fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>) + -> Result; +} + #[derive(Debug, Clone)] pub struct ProcMacro { pub name: SmolStr, pub kind: ProcMacroKind, - pub expander: Arc, + pub expander: Arc, } impl Eq for ProcMacro {} -- cgit v1.2.3