From 98baa9b569b49162392ed4149dd435854fe941b8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:22:05 +0200 Subject: Rename ra_arena --- Cargo.lock | 18 +-- crates/arena/Cargo.toml | 9 ++ crates/arena/src/lib.rs | 152 ++++++++++++++++++++++++ crates/arena/src/map.rs | 62 ++++++++++ crates/ra_arena/Cargo.toml | 9 -- crates/ra_arena/src/lib.rs | 152 ------------------------ crates/ra_arena/src/map.rs | 62 ---------- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_def/src/adt.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/body/lower.rs | 2 +- crates/ra_hir_def/src/body/scope.rs | 2 +- crates/ra_hir_def/src/expr.rs | 2 +- crates/ra_hir_def/src/generics.rs | 2 +- crates/ra_hir_def/src/item_tree.rs | 2 +- crates/ra_hir_def/src/item_tree/lower.rs | 2 +- crates/ra_hir_def/src/lib.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_hir_def/src/src.rs | 2 +- crates/ra_hir_def/src/trace.rs | 2 +- crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_hir_expand/src/ast_id_map.rs | 2 +- crates/ra_hir_ty/Cargo.toml | 2 +- crates/ra_hir_ty/src/db.rs | 2 +- crates/ra_hir_ty/src/diagnostics/match_check.rs | 2 +- crates/ra_hir_ty/src/infer.rs | 2 +- crates/ra_hir_ty/src/lower.rs | 2 +- crates/ra_prof/Cargo.toml | 2 +- crates/ra_prof/src/tree.rs | 4 +- crates/ra_project_model/Cargo.toml | 2 +- crates/ra_project_model/src/cargo_workspace.rs | 2 +- crates/ra_project_model/src/sysroot.rs | 2 +- 33 files changed, 259 insertions(+), 259 deletions(-) create mode 100644 crates/arena/Cargo.toml create mode 100644 crates/arena/src/lib.rs create mode 100644 crates/arena/src/map.rs delete mode 100644 crates/ra_arena/Cargo.toml delete mode 100644 crates/ra_arena/src/lib.rs delete mode 100644 crates/ra_arena/src/map.rs diff --git a/Cargo.lock b/Cargo.lock index 265889162..ab1698b11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,6 +45,10 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" +[[package]] +name = "arena" +version = "0.0.0" + [[package]] name = "arrayvec" version = "0.5.1" @@ -899,10 +903,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "ra_arena" -version = "0.1.0" - [[package]] name = "ra_assists" version = "0.1.0" @@ -977,6 +977,7 @@ name = "ra_hir_def" version = "0.1.0" dependencies = [ "anymap", + "arena", "drop_bomb", "either", "expect", @@ -985,7 +986,6 @@ dependencies = [ "itertools", "log", "once_cell", - "ra_arena", "ra_cfg", "ra_db", "ra_hir_expand", @@ -1003,9 +1003,9 @@ dependencies = [ name = "ra_hir_expand" version = "0.1.0" dependencies = [ + "arena", "either", "log", - "ra_arena", "ra_db", "ra_mbe", "ra_parser", @@ -1020,6 +1020,7 @@ dependencies = [ name = "ra_hir_ty" version = "0.1.0" dependencies = [ + "arena", "arrayvec", "chalk-ir", "chalk-recursive", @@ -1028,7 +1029,6 @@ dependencies = [ "expect", "itertools", "log", - "ra_arena", "ra_db", "ra_hir_def", "ra_hir_expand", @@ -1141,12 +1141,12 @@ dependencies = [ name = "ra_prof" version = "0.1.0" dependencies = [ + "arena", "backtrace", "cfg-if", "libc", "once_cell", "perf-event", - "ra_arena", ] [[package]] @@ -1154,10 +1154,10 @@ name = "ra_project_model" version = "0.1.0" dependencies = [ "anyhow", + "arena", "cargo_metadata", "log", "paths", - "ra_arena", "ra_cfg", "ra_db", "ra_proc_macro", diff --git a/crates/arena/Cargo.toml b/crates/arena/Cargo.toml new file mode 100644 index 000000000..f2bb5cc45 --- /dev/null +++ b/crates/arena/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "arena" +version = "0.0.0" +license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" + +[lib] +doctest = false diff --git a/crates/arena/src/lib.rs b/crates/arena/src/lib.rs new file mode 100644 index 000000000..3169aa5b8 --- /dev/null +++ b/crates/arena/src/lib.rs @@ -0,0 +1,152 @@ +//! Yet another index-based arena. + +use std::{ + fmt, + hash::{Hash, Hasher}, + iter::FromIterator, + marker::PhantomData, + ops::{Index, IndexMut}, +}; + +pub mod map; + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct RawId(u32); + +impl From for u32 { + fn from(raw: RawId) -> u32 { + raw.0 + } +} + +impl From for RawId { + fn from(id: u32) -> RawId { + RawId(id) + } +} + +impl fmt::Debug for RawId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +impl fmt::Display for RawId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} + +pub struct Idx { + raw: RawId, + _ty: PhantomData T>, +} + +impl Clone for Idx { + fn clone(&self) -> Self { + *self + } +} +impl Copy for Idx {} + +impl PartialEq for Idx { + fn eq(&self, other: &Idx) -> bool { + self.raw == other.raw + } +} +impl Eq for Idx {} + +impl Hash for Idx { + fn hash(&self, state: &mut H) { + self.raw.hash(state) + } +} + +impl fmt::Debug for Idx { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut type_name = std::any::type_name::(); + if let Some(idx) = type_name.rfind(':') { + type_name = &type_name[idx + 1..] + } + write!(f, "Idx::<{}>({})", type_name, self.raw) + } +} + +impl Idx { + pub fn from_raw(raw: RawId) -> Self { + Idx { raw, _ty: PhantomData } + } + pub fn into_raw(self) -> RawId { + self.raw + } +} + +#[derive(Clone, PartialEq, Eq)] +pub struct Arena { + data: Vec, +} + +impl fmt::Debug for Arena { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("Arena").field("len", &self.len()).field("data", &self.data).finish() + } +} + +impl Arena { + pub const fn new() -> Arena { + Arena { data: Vec::new() } + } + pub fn clear(&mut self) { + self.data.clear(); + } + + pub fn len(&self) -> usize { + self.data.len() + } + pub fn is_empty(&self) -> bool { + self.data.is_empty() + } + pub fn alloc(&mut self, value: T) -> Idx { + let id = RawId(self.data.len() as u32); + self.data.push(value); + Idx::from_raw(id) + } + pub fn iter( + &self, + ) -> impl Iterator, &T)> + ExactSizeIterator + DoubleEndedIterator { + self.data.iter().enumerate().map(|(idx, value)| (Idx::from_raw(RawId(idx as u32)), value)) + } + pub fn shrink_to_fit(&mut self) { + self.data.shrink_to_fit(); + } +} + +impl Default for Arena { + fn default() -> Arena { + Arena { data: Vec::new() } + } +} + +impl Index> for Arena { + type Output = T; + fn index(&self, idx: Idx) -> &T { + let idx = idx.into_raw().0 as usize; + &self.data[idx] + } +} + +impl IndexMut> for Arena { + fn index_mut(&mut self, idx: Idx) -> &mut T { + let idx = idx.into_raw().0 as usize; + &mut self.data[idx] + } +} + +impl FromIterator for Arena { + fn from_iter(iter: I) -> Self + where + I: IntoIterator, + { + Arena { data: Vec::from_iter(iter) } + } +} diff --git a/crates/arena/src/map.rs b/crates/arena/src/map.rs new file mode 100644 index 000000000..0f33907c0 --- /dev/null +++ b/crates/arena/src/map.rs @@ -0,0 +1,62 @@ +//! A map from arena IDs to some other type. Space requirement is O(highest ID). + +use std::marker::PhantomData; + +use crate::Idx; + +/// A map from arena IDs to some other type. Space requirement is O(highest ID). +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct ArenaMap { + v: Vec>, + _ty: PhantomData, +} + +impl ArenaMap, V> { + pub fn insert(&mut self, id: Idx, t: V) { + let idx = Self::to_idx(id); + + self.v.resize_with((idx + 1).max(self.v.len()), || None); + self.v[idx] = Some(t); + } + + pub fn get(&self, id: Idx) -> Option<&V> { + self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref()) + } + + pub fn get_mut(&mut self, id: Idx) -> Option<&mut V> { + self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut()) + } + + pub fn values(&self) -> impl Iterator { + self.v.iter().filter_map(|o| o.as_ref()) + } + + pub fn values_mut(&mut self) -> impl Iterator { + self.v.iter_mut().filter_map(|o| o.as_mut()) + } + + pub fn iter(&self) -> impl Iterator, &V)> { + self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) + } + + fn to_idx(id: Idx) -> usize { + u32::from(id.into_raw()) as usize + } + + fn from_idx(idx: usize) -> Idx { + Idx::from_raw((idx as u32).into()) + } +} + +impl std::ops::Index> for ArenaMap, T> { + type Output = T; + fn index(&self, id: Idx) -> &T { + self.v[Self::to_idx(id)].as_ref().unwrap() + } +} + +impl Default for ArenaMap, T> { + fn default() -> Self { + ArenaMap { v: Vec::new(), _ty: PhantomData } + } +} diff --git a/crates/ra_arena/Cargo.toml b/crates/ra_arena/Cargo.toml deleted file mode 100644 index 66c3738f4..000000000 --- a/crates/ra_arena/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -edition = "2018" -name = "ra_arena" -version = "0.1.0" -authors = ["rust-analyzer developers"] -license = "MIT OR Apache-2.0" - -[lib] -doctest = false diff --git a/crates/ra_arena/src/lib.rs b/crates/ra_arena/src/lib.rs deleted file mode 100644 index 3169aa5b8..000000000 --- a/crates/ra_arena/src/lib.rs +++ /dev/null @@ -1,152 +0,0 @@ -//! Yet another index-based arena. - -use std::{ - fmt, - hash::{Hash, Hasher}, - iter::FromIterator, - marker::PhantomData, - ops::{Index, IndexMut}, -}; - -pub mod map; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct RawId(u32); - -impl From for u32 { - fn from(raw: RawId) -> u32 { - raw.0 - } -} - -impl From for RawId { - fn from(id: u32) -> RawId { - RawId(id) - } -} - -impl fmt::Debug for RawId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) - } -} - -impl fmt::Display for RawId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) - } -} - -pub struct Idx { - raw: RawId, - _ty: PhantomData T>, -} - -impl Clone for Idx { - fn clone(&self) -> Self { - *self - } -} -impl Copy for Idx {} - -impl PartialEq for Idx { - fn eq(&self, other: &Idx) -> bool { - self.raw == other.raw - } -} -impl Eq for Idx {} - -impl Hash for Idx { - fn hash(&self, state: &mut H) { - self.raw.hash(state) - } -} - -impl fmt::Debug for Idx { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut type_name = std::any::type_name::(); - if let Some(idx) = type_name.rfind(':') { - type_name = &type_name[idx + 1..] - } - write!(f, "Idx::<{}>({})", type_name, self.raw) - } -} - -impl Idx { - pub fn from_raw(raw: RawId) -> Self { - Idx { raw, _ty: PhantomData } - } - pub fn into_raw(self) -> RawId { - self.raw - } -} - -#[derive(Clone, PartialEq, Eq)] -pub struct Arena { - data: Vec, -} - -impl fmt::Debug for Arena { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Arena").field("len", &self.len()).field("data", &self.data).finish() - } -} - -impl Arena { - pub const fn new() -> Arena { - Arena { data: Vec::new() } - } - pub fn clear(&mut self) { - self.data.clear(); - } - - pub fn len(&self) -> usize { - self.data.len() - } - pub fn is_empty(&self) -> bool { - self.data.is_empty() - } - pub fn alloc(&mut self, value: T) -> Idx { - let id = RawId(self.data.len() as u32); - self.data.push(value); - Idx::from_raw(id) - } - pub fn iter( - &self, - ) -> impl Iterator, &T)> + ExactSizeIterator + DoubleEndedIterator { - self.data.iter().enumerate().map(|(idx, value)| (Idx::from_raw(RawId(idx as u32)), value)) - } - pub fn shrink_to_fit(&mut self) { - self.data.shrink_to_fit(); - } -} - -impl Default for Arena { - fn default() -> Arena { - Arena { data: Vec::new() } - } -} - -impl Index> for Arena { - type Output = T; - fn index(&self, idx: Idx) -> &T { - let idx = idx.into_raw().0 as usize; - &self.data[idx] - } -} - -impl IndexMut> for Arena { - fn index_mut(&mut self, idx: Idx) -> &mut T { - let idx = idx.into_raw().0 as usize; - &mut self.data[idx] - } -} - -impl FromIterator for Arena { - fn from_iter(iter: I) -> Self - where - I: IntoIterator, - { - Arena { data: Vec::from_iter(iter) } - } -} diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs deleted file mode 100644 index 0f33907c0..000000000 --- a/crates/ra_arena/src/map.rs +++ /dev/null @@ -1,62 +0,0 @@ -//! A map from arena IDs to some other type. Space requirement is O(highest ID). - -use std::marker::PhantomData; - -use crate::Idx; - -/// A map from arena IDs to some other type. Space requirement is O(highest ID). -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct ArenaMap { - v: Vec>, - _ty: PhantomData, -} - -impl ArenaMap, V> { - pub fn insert(&mut self, id: Idx, t: V) { - let idx = Self::to_idx(id); - - self.v.resize_with((idx + 1).max(self.v.len()), || None); - self.v[idx] = Some(t); - } - - pub fn get(&self, id: Idx) -> Option<&V> { - self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref()) - } - - pub fn get_mut(&mut self, id: Idx) -> Option<&mut V> { - self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut()) - } - - pub fn values(&self) -> impl Iterator { - self.v.iter().filter_map(|o| o.as_ref()) - } - - pub fn values_mut(&mut self) -> impl Iterator { - self.v.iter_mut().filter_map(|o| o.as_mut()) - } - - pub fn iter(&self) -> impl Iterator, &V)> { - self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) - } - - fn to_idx(id: Idx) -> usize { - u32::from(id.into_raw()) as usize - } - - fn from_idx(idx: usize) -> Idx { - Idx::from_raw((idx as u32).into()) - } -} - -impl std::ops::Index> for ArenaMap, T> { - type Output = T; - fn index(&self, id: Idx) -> &T { - self.v[Self::to_idx(id)].as_ref().unwrap() - } -} - -impl Default for ArenaMap, T> { - fn default() -> Self { - ArenaMap { v: Vec::new(), _ty: PhantomData } - } -} diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index d96a86b80..6dd6fdde6 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -22,7 +22,7 @@ smallvec = "1.4.0" stdx = { path = "../stdx" } -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } ra_prof = { path = "../ra_prof" } diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 35c3a9140..896a69ca8 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -2,12 +2,12 @@ use std::sync::Arc; +use arena::{map::ArenaMap, Arena}; use either::Either; use hir_expand::{ name::{AsName, Name}, InFile, }; -use ra_arena::{map::ArenaMap, Arena}; use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index d5f18b920..cb178655b 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -5,10 +5,10 @@ pub mod scope; use std::{mem, ops::Index, sync::Arc}; +use arena::{map::ArenaMap, Arena}; use drop_bomb::DropBomb; use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; -use ra_arena::{map::ArenaMap, Arena}; use ra_cfg::CfgOptions; use ra_db::CrateId; use ra_prof::profile; diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index f5c37edb3..482393006 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -3,13 +3,13 @@ use std::{any::type_name, sync::Arc}; +use arena::Arena; use either::Either; use hir_expand::{ hygiene::Hygiene, name::{name, AsName, Name}, HirFileId, MacroDefId, MacroDefKind, }; -use ra_arena::Arena; use ra_syntax::{ ast::{ self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner, diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 99e876683..f783e18b5 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -1,8 +1,8 @@ //! Name resolution for expressions. use std::sync::Arc; +use arena::{Arena, Idx}; use hir_expand::name::Name; -use ra_arena::{Arena, Idx}; use rustc_hash::FxHashMap; use crate::{ diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index e41cfc16b..befe41c2a 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -12,8 +12,8 @@ //! //! See also a neighboring `body` module. +use arena::{Idx, RawId}; use hir_expand::name::Name; -use ra_arena::{Idx, RawId}; use ra_syntax::ast::RangeOp; use crate::{ diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 699ba9c92..90daa46b4 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -4,12 +4,12 @@ //! in rustc. use std::sync::Arc; +use arena::{map::ArenaMap, Arena}; use either::Either; use hir_expand::{ name::{name, AsName, Name}, InFile, }; -use ra_arena::{map::ArenaMap, Arena}; use ra_db::FileId; use ra_prof::profile; use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index a67e75dac..fc05bb307 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -13,6 +13,7 @@ use std::{ sync::Arc, }; +use arena::{Arena, Idx, RawId}; use ast::{AstNode, AttrsOwner, NameOwner, StructKind}; use either::Either; use hir_expand::{ @@ -21,7 +22,6 @@ use hir_expand::{ name::{name, AsName, Name}, HirFileId, InFile, }; -use ra_arena::{Arena, Idx, RawId}; use ra_syntax::{ast, match_ast}; use rustc_hash::FxHashMap; use smallvec::SmallVec; diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 450ef8798..4523d0fbb 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -2,8 +2,8 @@ use std::{collections::hash_map::Entry, mem, sync::Arc}; +use arena::map::ArenaMap; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; -use ra_arena::map::ArenaMap; use ra_syntax::{ ast::{self, ModuleItemOwner}, SyntaxNode, diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 237b1038a..810393739 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -52,11 +52,11 @@ mod test_db; use std::hash::{Hash, Hasher}; +use arena::Idx; use hir_expand::{ ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; -use ra_arena::Idx; use ra_db::{impl_intern_key, salsa, CrateId}; use ra_syntax::ast; diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 3d9b55a73..b4b97eb08 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -56,8 +56,8 @@ mod tests; use std::sync::Arc; +use arena::Arena; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; -use ra_arena::Arena; use ra_db::{CrateId, Edition, FileId}; use ra_prof::profile; use ra_syntax::ast; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 28b7a20c5..52ee401d9 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -1208,7 +1208,7 @@ fn is_macro_rules(path: &ModPath) -> bool { #[cfg(test)] mod tests { use crate::{db::DefDatabase, test_db::TestDB}; - use ra_arena::Arena; + use arena::Arena; use ra_db::{fixture::WithFixture, SourceDatabase}; use super::*; diff --git a/crates/ra_hir_def/src/src.rs b/crates/ra_hir_def/src/src.rs index 043b93fad..7a79b0314 100644 --- a/crates/ra_hir_def/src/src.rs +++ b/crates/ra_hir_def/src/src.rs @@ -1,7 +1,7 @@ //! Utilities for mapping between hir IDs and the surface syntax. +use arena::map::ArenaMap; use hir_expand::InFile; -use ra_arena::map::ArenaMap; use crate::{db::DefDatabase, item_tree::ItemTreeNode, AssocItemLoc, ItemLoc}; diff --git a/crates/ra_hir_def/src/trace.rs b/crates/ra_hir_def/src/trace.rs index ced07577d..fd64e7018 100644 --- a/crates/ra_hir_def/src/trace.rs +++ b/crates/ra_hir_def/src/trace.rs @@ -9,7 +9,7 @@ //! absolute offsets. The `Trace` structure (inspired, at least in name, by //! Kotlin's `BindingTrace`) allows use the same code to compute both //! projections. -use ra_arena::{map::ArenaMap, Arena, Idx, RawId}; +use arena::{map::ArenaMap, Arena, Idx, RawId}; pub(crate) struct Trace { arena: Option>, diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 6da0e2a16..808c36fd8 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -13,7 +13,7 @@ log = "0.4.8" either = "1.5.3" rustc-hash = "1.0.0" -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } ra_parser = { path = "../ra_parser" } diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs index 8bfe1b4ba..703a85b0f 100644 --- a/crates/ra_hir_expand/src/ast_id_map.rs +++ b/crates/ra_hir_expand/src/ast_id_map.rs @@ -12,7 +12,7 @@ use std::{ marker::PhantomData, }; -use ra_arena::{Arena, Idx}; +use arena::{Arena, Idx}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; /// `AstId` points to an AST node in a specific file. diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 83397d579..fc68eaa8f 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -20,7 +20,7 @@ stdx = { path = "../stdx" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_prof = { path = "../ra_prof" } ra_syntax = { path = "../ra_syntax" } diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index c773adc67..d396017bf 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -2,11 +2,11 @@ use std::sync::Arc; +use arena::map::ArenaMap; use hir_def::{ db::DefDatabase, expr::ExprId, DefWithBodyId, FunctionId, GenericDefId, ImplId, LocalFieldId, TypeParamId, VariantId, }; -use ra_arena::map::ArenaMap; use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; use ra_prof::profile; diff --git a/crates/ra_hir_ty/src/diagnostics/match_check.rs b/crates/ra_hir_ty/src/diagnostics/match_check.rs index deca244db..7f007f1d6 100644 --- a/crates/ra_hir_ty/src/diagnostics/match_check.rs +++ b/crates/ra_hir_ty/src/diagnostics/match_check.rs @@ -218,13 +218,13 @@ //! ``` use std::sync::Arc; +use arena::Idx; use hir_def::{ adt::VariantData, body::Body, expr::{Expr, Literal, Pat, PatId}, AdtId, EnumVariantId, VariantId, }; -use ra_arena::Idx; use smallvec::{smallvec, SmallVec}; use crate::{db::HirDatabase, ApplicationTy, InferenceResult, Ty, TypeCtor}; diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 3d12039a6..e003690b3 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -18,6 +18,7 @@ use std::mem; use std::ops::Index; use std::sync::Arc; +use arena::map::ArenaMap; use hir_def::{ body::Body, data::{ConstData, FunctionData, StaticData}, @@ -30,7 +31,6 @@ use hir_def::{ TypeAliasId, VariantId, }; use hir_expand::{diagnostics::DiagnosticSink, name::name}; -use ra_arena::map::ArenaMap; use ra_prof::profile; use ra_syntax::SmolStr; use rustc_hash::FxHashMap; diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 7638f167b..7b805fe7a 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -7,6 +7,7 @@ //! This usually involves resolving names, collecting generic arguments etc. use std::{iter, sync::Arc}; +use arena::map::ArenaMap; use hir_def::{ adt::StructKind, builtin_type::BuiltinType, @@ -19,7 +20,6 @@ use hir_def::{ UnionId, VariantId, }; use hir_expand::name::Name; -use ra_arena::map::ArenaMap; use ra_db::CrateId; use smallvec::SmallVec; use stdx::impl_from; diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index c82b9f76d..9880c587f 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" doctest = false [dependencies] -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } once_cell = "1.3.1" backtrace = { version = "0.3.44", optional = true } cfg-if = "0.1.10" diff --git a/crates/ra_prof/src/tree.rs b/crates/ra_prof/src/tree.rs index 9ea5b5db8..096f58511 100644 --- a/crates/ra_prof/src/tree.rs +++ b/crates/ra_prof/src/tree.rs @@ -1,7 +1,7 @@ //! A simple tree implementation which tries to not allocate all over the place. use std::ops; -use ra_arena::Arena; +use arena::Arena; #[derive(Default)] pub struct Tree { @@ -9,7 +9,7 @@ pub struct Tree { current_path: Vec<(Idx, Option>)>, } -pub type Idx = ra_arena::Idx>; +pub type Idx = arena::Idx>; impl Tree { pub fn start(&mut self) diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 99adea8e4..27b1f5d33 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml @@ -14,7 +14,7 @@ rustc-hash = "1.1.0" cargo_metadata = "0.11.1" -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_cfg = { path = "../ra_cfg" } ra_db = { path = "../ra_db" } ra_toolchain = { path = "../ra_toolchain" } diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 10513542e..a526d743d 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -8,9 +8,9 @@ use std::{ }; use anyhow::{Context, Result}; +use arena::{Arena, Idx}; use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; use paths::{AbsPath, AbsPathBuf}; -use ra_arena::{Arena, Idx}; use ra_db::Edition; use rustc_hash::FxHashMap; diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index a10ade375..6ef001769 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs @@ -3,8 +3,8 @@ use std::{convert::TryFrom, env, ops, path::Path, process::Command}; use anyhow::{bail, format_err, Result}; +use arena::{Arena, Idx}; use paths::{AbsPath, AbsPathBuf}; -use ra_arena::{Arena, Idx}; use crate::utf8_stdout; -- cgit v1.2.3