aboutsummaryrefslogtreecommitdiff
path: root/crates/base_db/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-11 13:57:50 +0000
committerJonas Schievink <[email protected]>2020-12-27 14:29:47 +0000
commit70877428a8d9f17834dee72f03ef80ce5c206e68 (patch)
tree60202937d17883cd862b1c788e6bde495a16dd2a /crates/base_db/src
parent798968e1e3a7d9eafa0c27c857571cdc347c34a7 (diff)
Pass crate environment to proc macros
Diffstat (limited to 'crates/base_db/src')
-rw-r--r--crates/base_db/src/input.rs12
1 files changed, 10 insertions, 2 deletions
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 {
151} 151}
152 152
153pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe { 153pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe {
154 fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>) 154 fn expand(
155 -> Result<Subtree, ExpansionError>; 155 &self,
156 subtree: &Subtree,
157 attrs: Option<&Subtree>,
158 env: &Env,
159 ) -> Result<Subtree, ExpansionError>;
156} 160}
157 161
158#[derive(Debug, Clone)] 162#[derive(Debug, Clone)]
@@ -418,6 +422,10 @@ impl Env {
418 pub fn get(&self, env: &str) -> Option<String> { 422 pub fn get(&self, env: &str) -> Option<String> {
419 self.entries.get(env).cloned() 423 self.entries.get(env).cloned()
420 } 424 }
425
426 pub fn iter(&self) -> impl Iterator<Item = (&str, &str)> {
427 self.entries.iter().map(|(k, v)| (k.as_str(), v.as_str()))
428 }
421} 429}
422 430
423#[derive(Debug)] 431#[derive(Debug)]