From 70877428a8d9f17834dee72f03ef80ce5c206e68 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 11 Dec 2020 14:57:50 +0100 Subject: Pass crate environment to proc macros --- crates/base_db/src/input.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/base_db/src') diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index a693e7f80..9567bcc42 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -151,8 +151,12 @@ pub enum ProcMacroKind { } pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe { - fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>) - -> Result; + fn expand( + &self, + subtree: &Subtree, + attrs: Option<&Subtree>, + env: &Env, + ) -> Result; } #[derive(Debug, Clone)] @@ -418,6 +422,10 @@ impl Env { pub fn get(&self, env: &str) -> Option { self.entries.get(env).cloned() } + + pub fn iter(&self) -> impl Iterator { + self.entries.iter().map(|(k, v)| (k.as_str(), v.as_str())) + } } #[derive(Debug)] -- cgit v1.2.3