diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-07 16:21:51 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-07 16:21:51 +0000 |
commit | c1824b4933f7a30b4253116290a0a6b2935eedc3 (patch) | |
tree | 30b2e506e326af121a716c92d42fc90229179072 /crates/base_db | |
parent | 9a88332452d661d4afea10f0063c893142e08019 (diff) | |
parent | 577d5f1c337d5de8719bddcabd3d22a560a11b95 (diff) |
Merge #6745
6745: Some more proc macro cleanups r=jonas-schievink a=jonas-schievink
* Remove `ProcMacroClient::dummy` and just use `Option<ProcMacroClient>` instead
* Remember the type of proc macros (later allows us to reject using an incorrect macro type)
* Prepare a few internals for procedural attribute macros
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/base_db')
-rw-r--r-- | crates/base_db/src/input.rs | 13 | ||||
-rw-r--r-- | crates/base_db/src/lib.rs | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 98ba372ad..cda5e57dc 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs | |||
@@ -143,9 +143,17 @@ impl CrateDisplayName { | |||
143 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 143 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
144 | pub struct ProcMacroId(pub u32); | 144 | pub struct ProcMacroId(pub u32); |
145 | 145 | ||
146 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | ||
147 | pub enum ProcMacroKind { | ||
148 | CustomDerive, | ||
149 | FuncLike, | ||
150 | Attr, | ||
151 | } | ||
152 | |||
146 | #[derive(Debug, Clone)] | 153 | #[derive(Debug, Clone)] |
147 | pub struct ProcMacro { | 154 | pub struct ProcMacro { |
148 | pub name: SmolStr, | 155 | pub name: SmolStr, |
156 | pub kind: ProcMacroKind, | ||
149 | pub expander: Arc<dyn TokenExpander>, | 157 | pub expander: Arc<dyn TokenExpander>, |
150 | } | 158 | } |
151 | 159 | ||
@@ -198,11 +206,8 @@ impl CrateGraph { | |||
198 | display_name: Option<CrateDisplayName>, | 206 | display_name: Option<CrateDisplayName>, |
199 | cfg_options: CfgOptions, | 207 | cfg_options: CfgOptions, |
200 | env: Env, | 208 | env: Env, |
201 | proc_macro: Vec<(SmolStr, Arc<dyn tt::TokenExpander>)>, | 209 | proc_macro: Vec<ProcMacro>, |
202 | ) -> CrateId { | 210 | ) -> CrateId { |
203 | let proc_macro = | ||
204 | proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect(); | ||
205 | |||
206 | let data = CrateData { | 211 | let data = CrateData { |
207 | root_file_id: file_id, | 212 | root_file_id: file_id, |
208 | edition, | 213 | edition, |
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index ce75a5337..5571af495 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -14,7 +14,7 @@ pub use crate::{ | |||
14 | change::Change, | 14 | change::Change, |
15 | input::{ | 15 | input::{ |
16 | CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, | 16 | CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, |
17 | ProcMacroId, SourceRoot, SourceRootId, | 17 | ProcMacro, ProcMacroId, ProcMacroKind, SourceRoot, SourceRootId, |
18 | }, | 18 | }, |
19 | }; | 19 | }; |
20 | pub use salsa; | 20 | pub use salsa; |