From db162df264a222021dbc7f1f93af94029f3948d9 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 27 Mar 2020 00:41:44 +0800 Subject: Remove deps on tt_mbe --- crates/ra_db/Cargo.toml | 2 +- crates/ra_db/src/input.rs | 23 ++++++++++++++++++++--- crates/ra_db/src/lib.rs | 1 - 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'crates/ra_db') diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 82fd842a6..8ab409158 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -15,5 +15,5 @@ rustc-hash = "1.1.0" ra_syntax = { path = "../ra_syntax" } ra_cfg = { path = "../ra_cfg" } ra_prof = { path = "../ra_prof" } -ra_proc_macro = { path = "../ra_proc_macro" } +ra_tt = { path = "../ra_tt" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 65b553a9f..5ddce98c6 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -10,6 +10,7 @@ use std::{ fmt, ops, path::{Path, PathBuf}, str::FromStr, + sync::Arc, }; use ra_cfg::CfgOptions; @@ -19,7 +20,7 @@ use rustc_hash::FxHashSet; use crate::{RelativePath, RelativePathBuf}; use fmt::Display; -use ra_proc_macro::ProcMacro; +use ra_tt::TokenExpander; /// `FileId` is an integer which uniquely identifies a file. File paths are /// messy and system-dependent, so most of the code should work directly with @@ -117,7 +118,20 @@ impl Display for CrateName { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct ProcMacroId(pub usize); +pub struct ProcMacroId(pub u32); + +#[derive(Debug, Clone)] +pub struct ProcMacro { + pub name: SmolStr, + pub expander: Arc, +} + +impl Eq for ProcMacro {} +impl PartialEq for ProcMacro { + fn eq(&self, other: &ProcMacro) -> bool { + self.name == other.name && Arc::ptr_eq(&self.expander, &other.expander) + } +} #[derive(Debug, Clone, PartialEq, Eq)] pub struct CrateData { @@ -171,8 +185,11 @@ impl CrateGraph { cfg_options: CfgOptions, env: Env, extern_source: ExternSource, - proc_macro: Vec, + proc_macro: Vec<(SmolStr, Arc)>, ) -> CrateId { + let proc_macro = + proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect(); + let data = CrateData { root_file_id: file_id, edition, diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 5829ae465..a06f59c14 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -15,7 +15,6 @@ pub use crate::{ FileId, ProcMacroId, SourceRoot, SourceRootId, }, }; -pub use ra_proc_macro::ProcMacro; pub use relative_path::{RelativePath, RelativePathBuf}; pub use salsa; -- cgit v1.2.3