//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
mod apply_change;
+
pub mod assists;
pub mod label;
pub mod line_index;
pub mod source_change;
pub mod ty_filter;
pub mod traits;
-pub mod call_info;
pub mod helpers;
pub mod path_transform;
pub mod search;
pub mod rename;
+pub mod active_parameter;
-use std::{fmt, sync::Arc};
+use std::{fmt, mem::ManuallyDrop, sync::Arc};
use base_db::{
salsa::{self, Durability},
/// `base_db` is normally also needed in places where `ide_db` is used, so this re-export is for convenience.
pub use base_db;
+pub type FxIndexSet<T> = indexmap::IndexSet<T, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
+pub type FxIndexMap<K, V> =
+ indexmap::IndexMap<K, V, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
+
#[salsa::database(
base_db::SourceDatabaseStorage,
base_db::SourceDatabaseExtStorage,
hir::db::HirDatabaseStorage
)]
pub struct RootDatabase {
- storage: salsa::Storage<RootDatabase>,
+ // We use `ManuallyDrop` here because every codegen unit that contains a
+ // `&RootDatabase -> &dyn OtherDatabase` cast will instantiate its drop glue in the vtable,
+ // which duplicates `Weak::drop` and `Arc::drop` tens of thousands of times, which makes
+ // compile times of all `ide_*` and downstream crates suffer greatly.
+ storage: ManuallyDrop<salsa::Storage<RootDatabase>>,
+}
+
+impl Drop for RootDatabase {
+ fn drop(&mut self) {
+ unsafe {
+ ManuallyDrop::drop(&mut self.storage);
+ }
+ }
}
impl fmt::Debug for RootDatabase {
impl RootDatabase {
pub fn new(lru_capacity: Option<usize>) -> RootDatabase {
- let mut db = RootDatabase { storage: salsa::Storage::default() };
+ let mut db = RootDatabase { storage: ManuallyDrop::new(salsa::Storage::default()) };
db.set_crate_graph_with_durability(Default::default(), Durability::HIGH);
db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
db.set_library_roots_with_durability(Default::default(), Durability::HIGH);
impl salsa::ParallelDatabase for RootDatabase {
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
- salsa::Snapshot::new(RootDatabase { storage: self.storage.snapshot() })
+ salsa::Snapshot::new(RootDatabase { storage: ManuallyDrop::new(self.storage.snapshot()) })
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum SymbolKind {
+ Attribute,
+ BuiltinAttr,
Const,
ConstParam,
+ Derive,
Enum,
Field,
Function,
SelfParam,
Static,
Struct,
+ ToolModule,
Trait,
TypeAlias,
TypeParam,
ValueParam,
Variant,
}
+
+impl From<hir::MacroKind> for SymbolKind {
+ fn from(it: hir::MacroKind) -> Self {
+ match it {
+ hir::MacroKind::Declarative | hir::MacroKind::BuiltIn | hir::MacroKind::ProcMacro => {
+ SymbolKind::Macro
+ }
+ hir::MacroKind::Derive => SymbolKind::Derive,
+ hir::MacroKind::Attr => SymbolKind::Attribute,
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ mod sourcegen_lints;
+}