Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--Cargo.lock3
-rw-r--r--crates/base-db/src/change.rs4
-rw-r--r--crates/base-db/src/lib.rs52
-rw-r--r--crates/hir-def/src/nameres/tests/incremental.rs2
-rw-r--r--crates/hir-def/src/test_db.rs5
-rw-r--r--crates/hir-expand/src/change.rs4
-rw-r--r--crates/hir-expand/src/lib.rs7
-rw-r--r--crates/hir-ty/src/test_db.rs5
-rw-r--r--crates/hir-ty/src/tests.rs2
-rw-r--r--crates/hir-ty/src/tests/incremental.rs2
-rw-r--r--crates/ide-assists/src/tests.rs2
-rw-r--r--crates/ide-completion/src/completions/mod_.rs2
-rw-r--r--crates/ide-completion/src/tests.rs2
-rw-r--r--crates/ide-db/src/helpers.rs2
-rw-r--r--crates/ide-db/src/lib.rs5
-rw-r--r--crates/ide-db/src/prime_caches.rs2
-rw-r--r--crates/ide-db/src/search.rs2
-rw-r--r--crates/ide-db/src/symbol_index.rs4
-rw-r--r--crates/ide-diagnostics/src/handlers/unlinked_file.rs4
-rw-r--r--crates/ide-diagnostics/src/tests.rs2
-rw-r--r--crates/ide-ssr/src/lib.rs6
-rw-r--r--crates/ide-ssr/src/search.rs2
-rw-r--r--crates/ide-ssr/src/tests.rs2
-rw-r--r--crates/ide/src/goto_definition.rs2
-rw-r--r--crates/ide/src/hover/tests.rs2
-rw-r--r--crates/ide/src/interpret_function.rs2
-rw-r--r--crates/ide/src/lib.rs4
-rw-r--r--crates/ide/src/static_index.rs2
-rw-r--r--crates/ide/src/view_crate_graph.rs2
-rw-r--r--crates/paths/Cargo.toml7
-rw-r--r--crates/proc-macro-api/Cargo.toml5
-rw-r--r--crates/proc-macro-api/src/msg.rs6
-rw-r--r--crates/proc-macro-api/src/msg/flat.rs8
-rw-r--r--crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs4
-rw-r--r--crates/proc-macro-srv/src/tests/utils.rs4
-rw-r--r--crates/project-model/src/workspace.rs11
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs2
-rw-r--r--crates/rust-analyzer/src/cli/diagnostics.rs2
-rw-r--r--crates/rust-analyzer/src/cli/run_tests.rs2
-rw-r--r--crates/rust-analyzer/src/cli/ssr.rs5
-rw-r--r--crates/rust-analyzer/src/global_state.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs2
-rw-r--r--crates/rust-analyzer/tests/slow-tests/main.rs2
-rw-r--r--crates/span/src/ast_id.rs39
-rw-r--r--crates/span/src/lib.rs7
-rw-r--r--crates/span/src/map.rs2
-rw-r--r--crates/test-fixture/src/lib.rs6
47 files changed, 129 insertions, 124 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e4f6ad28c1..b89bab1a6b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1268,6 +1268,7 @@ name = "paths"
version = "0.0.0"
dependencies = [
"camino",
+ "serde",
]
[[package]]
@@ -1330,14 +1331,12 @@ dependencies = [
"base-db",
"indexmap",
"intern",
- "la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"paths",
"rustc-hash",
"serde",
"serde_json",
"span",
"stdx",
- "text-size",
"tracing",
"tt",
]
diff --git a/crates/base-db/src/change.rs b/crates/base-db/src/change.rs
index 0fd54e1211..a9d91d64ce 100644
--- a/crates/base-db/src/change.rs
+++ b/crates/base-db/src/change.rs
@@ -7,7 +7,7 @@ use salsa::Durability;
use triomphe::Arc;
use vfs::FileId;
-use crate::{CrateGraph, SourceDatabaseExt, SourceDatabaseExt2, SourceRoot, SourceRootId};
+use crate::{CrateGraph, SourceDatabaseFileInputExt, SourceRoot, SourceRootDatabase, SourceRootId};
/// Encapsulate a bunch of raw `.set` calls on the database.
#[derive(Default)]
@@ -50,7 +50,7 @@ impl FileChange {
self.crate_graph = Some(graph);
}
- pub fn apply(self, db: &mut dyn SourceDatabaseExt) {
+ pub fn apply(self, db: &mut dyn SourceRootDatabase) {
let _p = tracing::info_span!("FileChange::apply").entered();
if let Some(roots) = self.roots {
for (idx, root) in roots.into_iter().enumerate() {
diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs
index f319f98537..20ef45d0b3 100644
--- a/crates/base-db/src/lib.rs
+++ b/crates/base-db/src/lib.rs
@@ -1,5 +1,5 @@
//! base_db defines basic database traits. The concrete DB is defined by ide.
-
+// FIXME: Rename this crate, base db is non descriptive
mod change;
mod input;
@@ -47,8 +47,6 @@ pub const DEFAULT_PARSE_LRU_CAP: u16 = 128;
pub const DEFAULT_BORROWCK_LRU_CAP: u16 = 2024;
pub trait FileLoader {
- /// Text of the file.
- fn file_text(&self, file_id: FileId) -> Arc<str>;
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId>;
/// Crates whose root's source root is the same as the source root of `file_id`
fn relevant_crates(&self, file_id: FileId) -> Arc<[CrateId]>;
@@ -58,6 +56,13 @@ pub trait FileLoader {
/// model. Everything else in rust-analyzer is derived from these queries.
#[salsa::query_group(SourceDatabaseStorage)]
pub trait SourceDatabase: FileLoader + std::fmt::Debug {
+ #[salsa::input]
+ fn compressed_file_text(&self, file_id: FileId) -> Arc<[u8]>;
+
+ /// Text of the file.
+ #[salsa::lru]
+ fn file_text(&self, file_id: FileId) -> Arc<str>;
+
/// Parses the file into the syntax tree.
#[salsa::lru]
fn parse(&self, file_id: EditionedFileId) -> Parse<ast::SourceFile>;
@@ -99,16 +104,18 @@ fn parse_errors(db: &dyn SourceDatabase, file_id: EditionedFileId) -> Option<Arc
}
}
+fn file_text(db: &dyn SourceDatabase, file_id: FileId) -> Arc<str> {
+ let bytes = db.compressed_file_text(file_id);
+ let bytes =
+ lz4_flex::decompress_size_prepended(&bytes).expect("lz4 decompression should not fail");
+ let text = std::str::from_utf8(&bytes).expect("file contents should be valid UTF-8");
+ Arc::from(text)
+}
+
/// We don't want to give HIR knowledge of source roots, hence we extract these
/// methods into a separate DB.
-#[salsa::query_group(SourceDatabaseExtStorage)]
-pub trait SourceDatabaseExt: SourceDatabase {
- #[salsa::input]
- fn compressed_file_text(&self, file_id: FileId) -> Arc<[u8]>;
-
- #[salsa::lru]
- fn file_text(&self, file_id: FileId) -> Arc<str>;
-
+#[salsa::query_group(SourceRootDatabaseStorage)]
+pub trait SourceRootDatabase: SourceDatabase {
/// Path to a file, relative to the root of its source root.
/// Source root of the file.
#[salsa::input]
@@ -121,15 +128,7 @@ pub trait SourceDatabaseExt: SourceDatabase {
fn source_root_crates(&self, id: SourceRootId) -> Arc<[CrateId]>;
}
-fn file_text(db: &dyn SourceDatabaseExt, file_id: FileId) -> Arc<str> {
- let bytes = db.compressed_file_text(file_id);
- let bytes =
- lz4_flex::decompress_size_prepended(&bytes).expect("lz4 decompression should not fail");
- let text = std::str::from_utf8(&bytes).expect("file contents should be valid UTF-8");
- Arc::from(text)
-}
-
-pub trait SourceDatabaseExt2 {
+pub trait SourceDatabaseFileInputExt {
fn set_file_text(&mut self, file_id: FileId, text: &str) {
self.set_file_text_with_durability(file_id, text, Durability::LOW);
}
@@ -142,7 +141,7 @@ pub trait SourceDatabaseExt2 {
);
}
-impl<Db: ?Sized + SourceDatabaseExt> SourceDatabaseExt2 for Db {
+impl<Db: ?Sized + SourceRootDatabase> SourceDatabaseFileInputExt for Db {
fn set_file_text_with_durability(
&mut self,
file_id: FileId,
@@ -159,7 +158,7 @@ impl<Db: ?Sized + SourceDatabaseExt> SourceDatabaseExt2 for Db {
}
}
-fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<[CrateId]> {
+fn source_root_crates(db: &dyn SourceRootDatabase, id: SourceRootId) -> Arc<[CrateId]> {
let graph = db.crate_graph();
let mut crates = graph
.iter()
@@ -173,13 +172,12 @@ fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<[Crat
crates.into_iter().collect()
}
-/// Silly workaround for cyclic deps between the traits
+// FIXME: Would be nice to get rid of this somehow
+/// Silly workaround for cyclic deps due to the SourceRootDatabase and SourceDatabase split
+/// regarding FileLoader
pub struct FileLoaderDelegate<T>(pub T);
-impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
- fn file_text(&self, file_id: FileId) -> Arc<str> {
- SourceDatabaseExt::file_text(self.0, file_id)
- }
+impl<T: SourceRootDatabase> FileLoader for FileLoaderDelegate<&'_ T> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
// FIXME: this *somehow* should be platform agnostic...
let source_root = self.0.file_source_root(path.anchor);
diff --git a/crates/hir-def/src/nameres/tests/incremental.rs b/crates/hir-def/src/nameres/tests/incremental.rs
index e82af31850..d319831867 100644
--- a/crates/hir-def/src/nameres/tests/incremental.rs
+++ b/crates/hir-def/src/nameres/tests/incremental.rs
@@ -1,4 +1,4 @@
-use base_db::{SourceDatabase, SourceDatabaseExt2 as _};
+use base_db::{SourceDatabase, SourceDatabaseFileInputExt as _};
use test_fixture::WithFixture;
use crate::{db::DefDatabase, nameres::tests::TestDB, AdtId, ModuleDefId};
diff --git a/crates/hir-def/src/test_db.rs b/crates/hir-def/src/test_db.rs
index f44472eae5..df9dec69d4 100644
--- a/crates/hir-def/src/test_db.rs
+++ b/crates/hir-def/src/test_db.rs
@@ -19,7 +19,7 @@ use crate::{
};
#[salsa::database(
- base_db::SourceDatabaseExtStorage,
+ base_db::SourceRootDatabaseStorage,
base_db::SourceDatabaseStorage,
hir_expand::db::ExpandDatabaseStorage,
crate::db::InternDatabaseStorage,
@@ -69,9 +69,6 @@ impl fmt::Debug for TestDB {
impl panic::RefUnwindSafe for TestDB {}
impl FileLoader for TestDB {
- fn file_text(&self, file_id: FileId) -> Arc<str> {
- FileLoaderDelegate(self).file_text(file_id)
- }
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
diff --git a/crates/hir-expand/src/change.rs b/crates/hir-expand/src/change.rs
index 1a3dd0e7dd..8b3f69db02 100644
--- a/crates/hir-expand/src/change.rs
+++ b/crates/hir-expand/src/change.rs
@@ -1,7 +1,7 @@
//! Defines a unit of change that can applied to the database to get the next
//! state. Changes are transactional.
use base_db::{
- salsa::Durability, CrateGraph, CrateId, FileChange, SourceDatabaseExt, SourceRoot,
+ salsa::Durability, CrateGraph, CrateId, FileChange, SourceRoot, SourceRootDatabase,
TargetLayoutLoadResult, Version,
};
use la_arena::RawIdx;
@@ -23,7 +23,7 @@ impl ChangeWithProcMacros {
Self::default()
}
- pub fn apply(self, db: &mut (impl ExpandDatabase + SourceDatabaseExt)) {
+ pub fn apply(self, db: &mut (impl ExpandDatabase + SourceRootDatabase)) {
self.source_change.apply(db);
if let Some(proc_macros) = self.proc_macros {
db.set_proc_macros_with_durability(Arc::new(proc_macros), Durability::HIGH);
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index 18da77d6ca..2bea902626 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -176,7 +176,12 @@ impl ExpandErrorKind {
&ExpandErrorKind::MissingProcMacroExpander(def_crate) => {
match db.proc_macros().get_error_for_crate(def_crate) {
Some((e, hard_err)) => (e.to_owned(), hard_err),
- None => ("missing expander".to_owned(), true),
+ None => (
+ format!(
+ "internal error: proc-macro map is missing error entry for crate {def_crate:?}"
+ ),
+ true,
+ ),
}
}
ExpandErrorKind::MacroDefinition => {
diff --git a/crates/hir-ty/src/test_db.rs b/crates/hir-ty/src/test_db.rs
index 108ae198d5..0efb9c52fb 100644
--- a/crates/hir-ty/src/test_db.rs
+++ b/crates/hir-ty/src/test_db.rs
@@ -15,7 +15,7 @@ use test_utils::extract_annotations;
use triomphe::Arc;
#[salsa::database(
- base_db::SourceDatabaseExtStorage,
+ base_db::SourceRootDatabaseStorage,
base_db::SourceDatabaseStorage,
hir_expand::db::ExpandDatabaseStorage,
hir_def::db::InternDatabaseStorage,
@@ -75,9 +75,6 @@ impl salsa::ParallelDatabase for TestDB {
impl panic::RefUnwindSafe for TestDB {}
impl FileLoader for TestDB {
- fn file_text(&self, file_id: FileId) -> Arc<str> {
- FileLoaderDelegate(self).file_text(file_id)
- }
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
diff --git a/crates/hir-ty/src/tests.rs b/crates/hir-ty/src/tests.rs
index e67124d57a..19619008e3 100644
--- a/crates/hir-ty/src/tests.rs
+++ b/crates/hir-ty/src/tests.rs
@@ -12,7 +12,7 @@ mod traits;
use std::env;
-use base_db::SourceDatabaseExt2 as _;
+use base_db::SourceDatabaseFileInputExt as _;
use expect_test::Expect;
use hir_def::{
body::{Body, BodySourceMap, SyntheticSyntax},
diff --git a/crates/hir-ty/src/tests/incremental.rs b/crates/hir-ty/src/tests/incremental.rs
index e9c62d3416..0a24eeb1fe 100644
--- a/crates/hir-ty/src/tests/incremental.rs
+++ b/crates/hir-ty/src/tests/incremental.rs
@@ -1,4 +1,4 @@
-use base_db::SourceDatabaseExt2 as _;
+use base_db::SourceDatabaseFileInputExt as _;
use test_fixture::WithFixture;
use crate::{db::HirDatabase, test_db::TestDB};
diff --git a/crates/ide-assists/src/tests.rs b/crates/ide-assists/src/tests.rs
index e42be636d7..6469957fe1 100644
--- a/crates/ide-assists/src/tests.rs
+++ b/crates/ide-assists/src/tests.rs
@@ -3,7 +3,7 @@ mod generated;
use expect_test::expect;
use hir::{FileRange, Semantics};
use ide_db::{
- base_db::SourceDatabaseExt,
+ base_db::{SourceDatabase, SourceRootDatabase},
imports::insert_use::{ImportGranularity, InsertUseConfig},
source_change::FileSystemEdit,
EditionedFileId, RootDatabase, SnippetCap,
diff --git a/crates/ide-completion/src/completions/mod_.rs b/crates/ide-completion/src/completions/mod_.rs
index 713968c1ca..d9a10893bf 100644
--- a/crates/ide-completion/src/completions/mod_.rs
+++ b/crates/ide-completion/src/completions/mod_.rs
@@ -4,7 +4,7 @@ use std::iter;
use hir::{HirFileIdExt, Module};
use ide_db::{
- base_db::{SourceDatabaseExt, VfsPath},
+ base_db::{SourceRootDatabase, VfsPath},
FxHashSet, RootDatabase, SymbolKind,
};
use stdx::IsNoneOr;
diff --git a/crates/ide-completion/src/tests.rs b/crates/ide-completion/src/tests.rs
index f6274cf537..415f2afeeb 100644
--- a/crates/ide-completion/src/tests.rs
+++ b/crates/ide-completion/src/tests.rs
@@ -23,10 +23,10 @@ mod type_pos;
mod use_tree;
mod visibility;
+use base_db::SourceDatabase;
use expect_test::Expect;
use hir::PrefixKind;
use ide_db::{
- base_db::FileLoader,
imports::insert_use::{ImportGranularity, InsertUseConfig},
FilePosition, RootDatabase, SnippetCap,
};
diff --git a/crates/ide-db/src/helpers.rs b/crates/ide-db/src/helpers.rs
index f6a781907d..e6638dde5d 100644
--- a/crates/ide-db/src/helpers.rs
+++ b/crates/ide-db/src/helpers.rs
@@ -2,7 +2,7 @@
use std::collections::VecDeque;
-use base_db::SourceDatabaseExt;
+use base_db::SourceRootDatabase;
use hir::{Crate, DescendPreference, ItemInNs, ModuleDef, Name, Semantics};
use span::FileId;
use syntax::{
diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs
index 4c52ba39de..cb1cf793d4 100644
--- a/crates/ide-db/src/lib.rs
+++ b/crates/ide-db/src/lib.rs
@@ -74,7 +74,7 @@ pub type FilePosition = FilePositionWrapper<FileId>;
pub type FileRange = FileRangeWrapper<FileId>;
#[salsa::database(
- base_db::SourceDatabaseExtStorage,
+ base_db::SourceRootDatabaseStorage,
base_db::SourceDatabaseStorage,
hir::db::ExpandDatabaseStorage,
hir::db::DefDatabaseStorage,
@@ -125,9 +125,6 @@ impl Upcast<dyn HirDatabase> for RootDatabase {
}
impl FileLoader for RootDatabase {
- fn file_text(&self, file_id: FileId) -> Arc<str> {
- FileLoaderDelegate(self).file_text(file_id)
- }
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
diff --git a/crates/ide-db/src/prime_caches.rs b/crates/ide-db/src/prime_caches.rs
index 62104fb7dc..bb121f4a80 100644
--- a/crates/ide-db/src/prime_caches.rs
+++ b/crates/ide-db/src/prime_caches.rs
@@ -11,7 +11,7 @@ use hir::db::DefDatabase;
use crate::{
base_db::{
salsa::{Database, ParallelDatabase, Snapshot},
- Cancelled, CrateId, SourceDatabase, SourceDatabaseExt,
+ Cancelled, CrateId, SourceDatabase, SourceRootDatabase,
},
FxIndexMap, RootDatabase,
};
diff --git a/crates/ide-db/src/search.rs b/crates/ide-db/src/search.rs
index 05b32e2a85..b6d17ce67e 100644
--- a/crates/ide-db/src/search.rs
+++ b/crates/ide-db/src/search.rs
@@ -6,7 +6,7 @@
use std::mem;
-use base_db::{salsa::Database, SourceDatabase, SourceDatabaseExt};
+use base_db::{salsa::Database, SourceDatabase, SourceRootDatabase};
use hir::{
sym, AsAssocItem, DefWithBody, DescendPreference, FileRange, HasAttrs, HasSource, HirFileIdExt,
InFile, InRealFile, ModuleSource, PathResolution, Semantics, Visibility,
diff --git a/crates/ide-db/src/symbol_index.rs b/crates/ide-db/src/symbol_index.rs
index c70aed4c43..209b1477ba 100644
--- a/crates/ide-db/src/symbol_index.rs
+++ b/crates/ide-db/src/symbol_index.rs
@@ -29,7 +29,7 @@ use std::{
use base_db::{
salsa::{self, ParallelDatabase},
- SourceDatabaseExt, SourceRootId, Upcast,
+ SourceRootDatabase, SourceRootId, Upcast,
};
use fst::{raw::IndexedValue, Automaton, Streamer};
use hir::{
@@ -100,7 +100,7 @@ impl Query {
}
#[salsa::query_group(SymbolsDatabaseStorage)]
-pub trait SymbolsDatabase: HirDatabase + SourceDatabaseExt + Upcast<dyn HirDatabase> {
+pub trait SymbolsDatabase: HirDatabase + SourceRootDatabase + Upcast<dyn HirDatabase> {
/// The symbol index for a given module. These modules should only be in source roots that
/// are inside local_roots.
fn module_symbols(&self, module: Module) -> Arc<SymbolIndex>;
diff --git a/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
index 1b71a3a3e6..b229ba8084 100644
--- a/crates/ide-diagnostics/src/handlers/unlinked_file.rs
+++ b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
@@ -4,7 +4,7 @@ use std::iter;
use hir::{db::DefDatabase, DefMap, InFile, ModuleSource};
use ide_db::{
- base_db::{FileLoader, SourceDatabaseExt},
+ base_db::{FileLoader, SourceDatabase, SourceRootDatabase},
source_change::SourceChange,
FileId, FileRange, LineIndexDatabase,
};
@@ -47,7 +47,7 @@ pub(crate) fn unlinked_file(
//
// Only show this diagnostic on the first three characters of
// the file, to avoid overwhelming the user during startup.
- range = FileLoader::file_text(ctx.sema.db, file_id)
+ range = SourceDatabase::file_text(ctx.sema.db, file_id)
.char_indices()
.take(3)
.last()
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index e56fca1e50..e943503522 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -1,7 +1,7 @@
#![allow(clippy::print_stderr)]
use ide_db::{
- assists::AssistResolveStrategy, base_db::SourceDatabaseExt, LineIndexDatabase, RootDatabase,
+ assists::AssistResolveStrategy, base_db::SourceDatabase, LineIndexDatabase, RootDatabase,
};
use itertools::Itertools;
use stdx::trim_indent;
diff --git a/crates/ide-ssr/src/lib.rs b/crates/ide-ssr/src/lib.rs
index e62ef60433..54236ea8bc 100644
--- a/crates/ide-ssr/src/lib.rs
+++ b/crates/ide-ssr/src/lib.rs
@@ -84,7 +84,7 @@ pub use crate::{errors::SsrError, from_comment::ssr_from_comment, matching::Matc
use crate::{errors::bail, matching::MatchFailureReason};
use hir::{FileRange, Semantics};
-use ide_db::{EditionedFileId, FileId, FxHashMap, RootDatabase};
+use ide_db::{base_db::SourceDatabase, EditionedFileId, FileId, FxHashMap, RootDatabase};
use resolving::ResolvedRule;
use syntax::{ast, AstNode, SyntaxNode, TextRange};
use text_edit::TextEdit;
@@ -141,7 +141,7 @@ impl<'db> MatchFinder<'db> {
/// Constructs an instance using the start of the first file in `db` as the lookup context.
pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> {
- use ide_db::base_db::SourceDatabaseExt;
+ use ide_db::base_db::SourceRootDatabase;
use ide_db::symbol_index::SymbolsDatabase;
if let Some(first_file_id) =
db.local_roots().iter().next().and_then(|root| db.source_root(*root).iter().next())
@@ -172,7 +172,6 @@ impl<'db> MatchFinder<'db> {
/// Finds matches for all added rules and returns edits for all found matches.
pub fn edits(&self) -> FxHashMap<FileId, TextEdit> {
- use ide_db::base_db::SourceDatabaseExt;
let mut matches_by_file = FxHashMap::default();
for m in self.matches().matches {
matches_by_file
@@ -228,7 +227,6 @@ impl<'db> MatchFinder<'db> {
file_id: EditionedFileId,
snippet: &str,
) -> Vec<MatchDebugInfo> {
- use ide_db::base_db::SourceDatabaseExt;
let file = self.sema.parse(file_id);
let mut res = Vec::new();
let file_text = self.sema.db.file_text(file_id.into());
diff --git a/crates/ide-ssr/src/search.rs b/crates/ide-ssr/src/search.rs
index 832386685d..241de10b44 100644
--- a/crates/ide-ssr/src/search.rs
+++ b/crates/ide-ssr/src/search.rs
@@ -156,7 +156,7 @@ impl MatchFinder<'_> {
fn search_files_do(&self, mut callback: impl FnMut(FileId)) {
if self.restrict_ranges.is_empty() {
// Unrestricted search.
- use ide_db::base_db::SourceDatabaseExt;
+ use ide_db::base_db::SourceRootDatabase;
use ide_db::symbol_index::SymbolsDatabase;
for &root in self.sema.db.local_roots().iter() {
let sr = self.sema.db.source_root(root);
diff --git a/crates/ide-ssr/src/tests.rs b/crates/ide-ssr/src/tests.rs
index 4477a268b2..42930889d7 100644
--- a/crates/ide-ssr/src/tests.rs
+++ b/crates/ide-ssr/src/tests.rs
@@ -1,7 +1,7 @@
use expect_test::{expect, Expect};
use hir::{FilePosition, FileRange};
use ide_db::{
- base_db::{salsa::Durability, SourceDatabaseExt},
+ base_db::{salsa::Durability, SourceDatabase},
EditionedFileId, FxHashSet,
};
use test_utils::RangeOrOffset;
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index d0701a45b1..8a8bc07945 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -10,7 +10,7 @@ use hir::{
Semantics,
};
use ide_db::{
- base_db::{AnchoredPath, FileLoader},
+ base_db::{AnchoredPath, FileLoader, SourceDatabase},
defs::{Definition, IdentClass},
helpers::pick_best_token,
RootDatabase, SymbolKind,
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 3257305184..ecfcf82e00 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -1,5 +1,5 @@
use expect_test::{expect, Expect};
-use ide_db::{base_db::FileLoader, FileRange};
+use ide_db::{base_db::SourceDatabase, FileRange};
use syntax::TextRange;
use crate::{
diff --git a/crates/ide/src/interpret_function.rs b/crates/ide/src/interpret_function.rs
index aeb3c8c1ee..ff1317d135 100644
--- a/crates/ide/src/interpret_function.rs
+++ b/crates/ide/src/interpret_function.rs
@@ -1,5 +1,5 @@
use hir::Semantics;
-use ide_db::{base_db::SourceDatabaseExt, FilePosition, LineIndexDatabase, RootDatabase};
+use ide_db::{base_db::SourceRootDatabase, FilePosition, LineIndexDatabase, RootDatabase};
use std::{fmt::Write, time::Instant};
use syntax::{algo::ancestors_at_offset, ast, AstNode, TextRange};
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 8cb81a9cc4..4624f6bfcf 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -65,7 +65,7 @@ use hir::{sym, ChangeWithProcMacros};
use ide_db::{
base_db::{
salsa::{self, ParallelDatabase},
- CrateOrigin, Env, FileLoader, FileSet, SourceDatabase, SourceDatabaseExt, VfsPath,
+ CrateOrigin, Env, FileLoader, FileSet, SourceDatabase, SourceRootDatabase, VfsPath,
},
prime_caches, symbol_index, FxHashMap, FxIndexSet, LineIndexDatabase,
};
@@ -286,7 +286,7 @@ impl Analysis {
/// Gets the text of the source file.
pub fn file_text(&self, file_id: FileId) -> Cancellable<Arc<str>> {
- self.with_db(|db| SourceDatabaseExt::file_text(db, file_id))
+ self.with_db(|db| SourceDatabase::file_text(db, file_id))
}
/// Gets the syntax tree of the file.
diff --git a/crates/ide/src/static_index.rs b/crates/ide/src/static_index.rs
index cd9b7ae2f6..f688adff28 100644
--- a/crates/ide/src/static_index.rs
+++ b/crates/ide/src/static_index.rs
@@ -3,7 +3,7 @@
use hir::{db::HirDatabase, Crate, HirFileIdExt, Module, Semantics};
use ide_db::{
- base_db::SourceDatabaseExt, defs::Definition, documentation::Documentation,
+ base_db::SourceRootDatabase, defs::Definition, documentation::Documentation,
famous_defs::FamousDefs, helpers::get_definition, FileId, FileRange, FxHashMap, FxHashSet,
RootDatabase,
};
diff --git a/crates/ide/src/view_crate_graph.rs b/crates/ide/src/view_crate_graph.rs
index 727012112e..9ff099f479 100644
--- a/crates/ide/src/view_crate_graph.rs
+++ b/crates/ide/src/view_crate_graph.rs
@@ -1,6 +1,6 @@
use dot::{Id, LabelText};
use ide_db::{
- base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt},
+ base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceRootDatabase},
FxHashSet, RootDatabase,
};
use triomphe::Arc;
diff --git a/crates/paths/Cargo.toml b/crates/paths/Cargo.toml
index 59a4ad9a25..b51892c265 100644
--- a/crates/paths/Cargo.toml
+++ b/crates/paths/Cargo.toml
@@ -13,13 +13,10 @@ doctest = false
[dependencies]
camino.workspace = true
-# Adding this dep sadly puts a lot of rust-analyzer crates after the
-# serde-derive crate. Even though we don't activate the derive feature here,
-# someone else in the crate graph certainly does!
-# serde.workspace = true
+serde = { workspace = true, optional = true }
[features]
-serde1 = ["camino/serde1"]
+serde1 = ["camino/serde1", "dep:serde"]
[lints]
workspace = true
diff --git a/crates/proc-macro-api/Cargo.toml b/crates/proc-macro-api/Cargo.toml
index 345fb9f8ae..3e6f80878b 100644
--- a/crates/proc-macro-api/Cargo.toml
+++ b/crates/proc-macro-api/Cargo.toml
@@ -22,12 +22,11 @@ indexmap.workspace = true
paths = { workspace = true, features = ["serde1"] }
tt.workspace = true
stdx.workspace = true
-text-size.workspace = true
-span.workspace = true
# Ideally this crate would not depend on salsa things, but we need span information here which wraps
# InternIds for the syntax context
+span.workspace = true
+# only here due to the `Env` newtype :/
base-db.workspace = true
-la-arena.workspace = true
intern.workspace = true
[lints]
diff --git a/crates/proc-macro-api/src/msg.rs b/crates/proc-macro-api/src/msg.rs
index 6a99b5ed1c..883528558d 100644
--- a/crates/proc-macro-api/src/msg.rs
+++ b/crates/proc-macro-api/src/msg.rs
@@ -158,9 +158,7 @@ type ProtocolWrite<W: Write> = for<'o, 'msg> fn(out: &'o mut W, msg: &'msg str)
#[cfg(test)]
mod tests {
use intern::{sym, Symbol};
- use la_arena::RawIdx;
- use span::{ErasedFileAstId, Span, SpanAnchor, SyntaxContextId};
- use text_size::{TextRange, TextSize};
+ use span::{ErasedFileAstId, Span, SpanAnchor, SyntaxContextId, TextRange, TextSize};
use tt::{Delimiter, DelimiterKind, Ident, Leaf, Literal, Punct, Spacing, Subtree, TokenTree};
use super::*;
@@ -171,7 +169,7 @@ mod tests {
span::FileId::from_raw(0xe4e4e),
span::Edition::CURRENT,
),
- ast_id: ErasedFileAstId::from_raw(RawIdx::from(0)),
+ ast_id: ErasedFileAstId::from_raw(0),
};
let token_trees = Box::new([
diff --git a/crates/proc-macro-api/src/msg/flat.rs b/crates/proc-macro-api/src/msg/flat.rs
index a8661f59b2..88256e98b5 100644
--- a/crates/proc-macro-api/src/msg/flat.rs
+++ b/crates/proc-macro-api/src/msg/flat.rs
@@ -38,11 +38,9 @@
use std::collections::VecDeque;
use intern::Symbol;
-use la_arena::RawIdx;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
-use span::{EditionedFileId, ErasedFileAstId, Span, SpanAnchor, SyntaxContextId};
-use text_size::TextRange;
+use span::{EditionedFileId, ErasedFileAstId, Span, SpanAnchor, SyntaxContextId, TextRange};
use crate::msg::{ENCODE_CLOSE_SPAN_VERSION, EXTENDED_LEAF_DATA};
@@ -54,7 +52,7 @@ pub fn serialize_span_data_index_map(map: &SpanDataIndexMap) -> Vec<u32> {
.flat_map(|span| {
[
span.anchor.file_id.as_u32(),
- span.anchor.ast_id.into_raw().into_u32(),
+ span.anchor.ast_id.into_raw(),
span.range.start().into(),
span.range.end().into(),
span.ctx.into_u32(),
@@ -71,7 +69,7 @@ pub fn deserialize_span_data_index_map(map: &[u32]) -> SpanDataIndexMap {
Span {
anchor: SpanAnchor {
file_id: EditionedFileId::from_raw(file_id),
- ast_id: ErasedFileAstId::from_raw(RawIdx::from_u32(ast_id)),
+ ast_id: ErasedFileAstId::from_raw(ast_id),
},
range: TextRange::new(start.into(), end.into()),
ctx: SyntaxContextId::from_u32(e),
diff --git a/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
index 8b9eb3beb6..552d99f51b 100644
--- a/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
+++ b/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
@@ -479,7 +479,7 @@ mod tests {
range: TextRange::empty(TextSize::new(0)),
anchor: span::SpanAnchor {
file_id: EditionedFileId::current_edition(FileId::from_raw(0)),
- ast_id: span::ErasedFileAstId::from_raw(0.into()),
+ ast_id: span::ErasedFileAstId::from_raw(0),
},
ctx: SyntaxContextId::ROOT,
};
@@ -515,7 +515,7 @@ mod tests {
range: TextRange::empty(TextSize::new(0)),
anchor: span::SpanAnchor {
file_id: EditionedFileId::current_edition(FileId::from_raw(0)),
- ast_id: span::ErasedFileAstId::from_raw(0.into()),
+ ast_id: span::ErasedFileAstId::from_raw(0),
},
ctx: SyntaxContextId::ROOT,
};
diff --git a/crates/proc-macro-srv/src/tests/utils.rs b/crates/proc-macro-srv/src/tests/utils.rs
index 70eff51cad..ded985877c 100644
--- a/crates/proc-macro-srv/src/tests/utils.rs
+++ b/crates/proc-macro-srv/src/tests/utils.rs
@@ -69,7 +69,7 @@ fn assert_expand_impl(
range: TextRange::new(0.into(), 150.into()),
anchor: SpanAnchor {
file_id: EditionedFileId::current_edition(FileId::from_raw(41)),
- ast_id: ErasedFileAstId::from_raw(From::from(1)),
+ ast_id: ErasedFileAstId::from_raw(1),
},
ctx: SyntaxContextId::ROOT,
};
@@ -77,7 +77,7 @@ fn assert_expand_impl(
range: TextRange::new(0.into(), 100.into()),
anchor: SpanAnchor {
file_id: EditionedFileId::current_edition(FileId::from_raw(42)),
- ast_id: ErasedFileAstId::from_raw(From::from(2)),
+ ast_id: ErasedFileAstId::from_raw(2),
},
ctx: SyntaxContextId::ROOT,
};
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index c90543d0ea..9156c8da33 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -1349,12 +1349,13 @@ fn add_target_crate_root(
);
if let TargetKind::Lib { is_proc_macro: true } = kind {
let proc_macro = match build_data.as_ref().map(|it| it.proc_macro_dylib_path.as_ref()) {
- Some(it) => it.cloned().map(|path| Ok((cargo_name.to_owned(), path))),
- None => Some(Err("proc-macro crate is missing its build data".to_owned())),
+ Some(it) => match it {
+ Some(path) => Ok((cargo_name.to_owned(), path.clone())),
+ None => Err("proc-macro crate build data is missing dylib path".to_owned()),
+ },
+ None => Err("proc-macro crate is missing its build data".to_owned()),
};
- if let Some(proc_macro) = proc_macro {
- proc_macros.insert(crate_id, proc_macro);
- }
+ proc_macros.insert(crate_id, proc_macro);
}
crate_id
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 41b59ab0d0..cf5508bb7f 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -23,7 +23,7 @@ use ide::{
use ide_db::{
base_db::{
salsa::{self, debug::DebugQueryTable, ParallelDatabase},
- SourceDatabase, SourceDatabaseExt,
+ SourceDatabase, SourceRootDatabase,
},
EditionedFileId, LineIndexDatabase, SnippetCap,
};
diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs
index 4ddeb4ab1b..5ec657a227 100644
--- a/crates/rust-analyzer/src/cli/diagnostics.rs
+++ b/crates/rust-analyzer/src/cli/diagnostics.rs
@@ -6,7 +6,7 @@ use rustc_hash::FxHashSet;
use hir::{db::HirDatabase, Crate, HirFileIdExt, Module};
use ide::{AnalysisHost, AssistResolveStrategy, Diagnostic, DiagnosticsConfig, Severity};
-use ide_db::{base_db::SourceDatabaseExt, LineIndexDatabase};
+use ide_db::{base_db::SourceRootDatabase, LineIndexDatabase};
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
use crate::cli::flags;
diff --git a/crates/rust-analyzer/src/cli/run_tests.rs b/crates/rust-analyzer/src/cli/run_tests.rs
index 10cb2d5ad6..157ef43dd0 100644
--- a/crates/rust-analyzer/src/cli/run_tests.rs
+++ b/crates/rust-analyzer/src/cli/run_tests.rs
@@ -2,7 +2,7 @@
use hir::{Crate, Module};
use hir_ty::db::HirDatabase;
-use ide_db::{base_db::SourceDatabaseExt, LineIndexDatabase};
+use ide_db::{base_db::SourceRootDatabase, LineIndexDatabase};
use profile::StopWatch;
use project_model::{CargoConfig, RustLibSource};
use syntax::TextRange;
diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs
index 7f24fa2835..3caa487988 100644
--- a/crates/rust-analyzer/src/cli/ssr.rs
+++ b/crates/rust-analyzer/src/cli/ssr.rs
@@ -1,7 +1,7 @@
//! Applies structured search replace rules from the command line.
use anyhow::Context;
-use ide_db::EditionedFileId;
+use ide_db::{base_db::SourceDatabase, EditionedFileId};
use ide_ssr::MatchFinder;
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
use project_model::{CargoConfig, RustLibSource};
@@ -10,7 +10,6 @@ use crate::cli::flags;
impl flags::Ssr {
pub fn run(self) -> anyhow::Result<()> {
- use ide_db::base_db::SourceDatabaseExt;
let cargo_config =
CargoConfig { sysroot: Some(RustLibSource::Discover), ..Default::default() };
let load_cargo_config = LoadCargoConfig {
@@ -46,7 +45,7 @@ impl flags::Search {
/// `debug_snippet`. This is intended for debugging and probably isn't in it's current form useful
/// for much else.
pub fn run(self) -> anyhow::Result<()> {
- use ide_db::base_db::SourceDatabaseExt;
+ use ide_db::base_db::SourceRootDatabase;
use ide_db::symbol_index::SymbolsDatabase;
let cargo_config = CargoConfig::default();
let load_cargo_config = LoadCargoConfig {
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index f1dde104fc..2ed56a7fd6 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -9,7 +9,7 @@ use crossbeam_channel::{unbounded, Receiver, Sender};
use flycheck::{project_json, FlycheckHandle};
use hir::ChangeWithProcMacros;
use ide::{Analysis, AnalysisHost, Cancellable, FileId, SourceRootId};
-use ide_db::base_db::{CrateId, ProcMacroPaths, SourceDatabaseExt};
+use ide_db::base_db::{CrateId, ProcMacroPaths, SourceDatabase, SourceRootDatabase};
use itertools::Itertools;
use load_cargo::SourceRootConfig;
use lsp_types::{SemanticTokens, Url};
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 9c820749ec..f8989b8479 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -10,7 +10,7 @@ use std::{
use always_assert::always;
use crossbeam_channel::{select, Receiver};
use flycheck::project_json;
-use ide_db::base_db::{SourceDatabase, SourceDatabaseExt, VfsPath};
+use ide_db::base_db::{SourceDatabase, SourceRootDatabase, VfsPath};
use lsp_server::{Connection, Notification, Request};
use lsp_types::{notification::Notification as _, TextDocumentIdentifier};
use stdx::thread::ThreadIntent;
diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs
index b1ef483771..c5b9fee6b1 100644
--- a/crates/rust-analyzer/tests/slow-tests/main.rs
+++ b/crates/rust-analyzer/tests/slow-tests/main.rs
@@ -1084,7 +1084,6 @@ fn resolve_proc_macro() {
let sysroot = project_model::Sysroot::discover(
&AbsPathBuf::assert_utf8(std::env::current_dir().unwrap()),
&Default::default(),
- false,
);
let proc_macro_server_path = sysroot.discover_proc_macro_srv().unwrap();
@@ -1125,7 +1124,6 @@ edition = "2021"
proc-macro = true
//- /bar/src/lib.rs
-extern crate proc_macro;
use proc_macro::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
macro_rules! t {
($n:literal) => {
diff --git a/crates/span/src/ast_id.rs b/crates/span/src/ast_id.rs
index b61baa2244..0ebd72e151 100644
--- a/crates/span/src/ast_id.rs
+++ b/crates/span/src/ast_id.rs
@@ -18,7 +18,28 @@ use syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr};
/// See crates\hir-expand\src\ast_id_map.rs
/// This is a type erased FileAstId.
-pub type ErasedFileAstId = la_arena::Idx<syntax::SyntaxNodePtr>;
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
+pub struct ErasedFileAstId(u32);
+
+impl ErasedFileAstId {
+ pub const fn into_raw(self) -> u32 {
+ self.0
+ }
+ pub const fn from_raw(u32: u32) -> Self {
+ Self(u32)
+ }
+}
+
+impl fmt::Display for ErasedFileAstId {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+impl fmt::Debug for ErasedFileAstId {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
/// `AstId` points to an AST node in a specific file.
pub struct FileAstId<N: AstIdNode> {
@@ -47,7 +68,7 @@ impl<N: AstIdNode> Hash for FileAstId<N> {
impl<N: AstIdNode> fmt::Debug for FileAstId<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "FileAstId::<{}>({})", type_name::<N>(), self.raw.into_raw())
+ write!(f, "FileAstId::<{}>({})", type_name::<N>(), self.raw)
}
}
@@ -176,7 +197,10 @@ impl AstIdMap {
let ptr = ptr.syntax_node_ptr();
let hash = hash_ptr(&ptr);
match self.map.raw_entry().from_hash(hash, |&idx| self.arena[idx] == ptr) {
- Some((&raw, &())) => FileAstId { raw, covariant: PhantomData },
+ Some((&raw, &())) => FileAstId {
+ raw: ErasedFileAstId(raw.into_raw().into_u32()),
+ covariant: PhantomData,
+ },
None => panic!(
"Can't find {:?} in AstIdMap:\n{:?}",
ptr,
@@ -186,18 +210,19 @@ impl AstIdMap {
}
pub fn get<N: AstIdNode>(&self, id: FileAstId<N>) -> AstPtr<N> {
- AstPtr::try_from_raw(self.arena[id.raw]).unwrap()
+ AstPtr::try_from_raw(self.arena[Idx::from_raw(RawIdx::from_u32(id.raw.into_raw()))])
+ .unwrap()
}
pub fn get_erased(&self, id: ErasedFileAstId) -> SyntaxNodePtr {
- self.arena[id]
+ self.arena[Idx::from_raw(RawIdx::from_u32(id.into_raw()))]
}
fn erased_ast_id(&self, item: &SyntaxNode) -> ErasedFileAstId {
let ptr = SyntaxNodePtr::new(item);
let hash = hash_ptr(&ptr);
match self.map.raw_entry().from_hash(hash, |&idx| self.arena[idx] == ptr) {
- Some((&idx, &())) => idx,
+ Some((&idx, &())) => ErasedFileAstId(idx.into_raw().into_u32()),
None => panic!(
"Can't find {:?} in AstIdMap:\n{:?}",
item,
@@ -207,7 +232,7 @@ impl AstIdMap {
}
fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId {
- self.arena.alloc(SyntaxNodePtr::new(item))
+ ErasedFileAstId(self.arena.alloc(SyntaxNodePtr::new(item)).into_raw().into_u32())
}
}
diff --git a/crates/span/src/lib.rs b/crates/span/src/lib.rs
index b4e21d64f8..61e4c98128 100644
--- a/crates/span/src/lib.rs
+++ b/crates/span/src/lib.rs
@@ -21,15 +21,14 @@ pub use vfs::FileId;
/// The root ast id always points to the encompassing file, using this in spans is discouraged as
/// any range relative to it will be effectively absolute, ruining the entire point of anchored
/// relative text ranges.
-pub const ROOT_ERASED_FILE_AST_ID: ErasedFileAstId =
- la_arena::Idx::from_raw(la_arena::RawIdx::from_u32(0));
+pub const ROOT_ERASED_FILE_AST_ID: ErasedFileAstId = ErasedFileAstId::from_raw(0);
/// FileId used as the span for syntax node fixups. Any Span containing this file id is to be
/// considered fake.
pub const FIXUP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId =
- // we pick the second to last for this in case we every consider making this a NonMaxU32, this
+ // we pick the second to last for this in case we ever consider making this a NonMaxU32, this
// is required to be stable for the proc-macro-server
- la_arena::Idx::from_raw(la_arena::RawIdx::from_u32(!0 - 1));
+ ErasedFileAstId::from_raw(!0 - 1);
pub type Span = SpanData<SyntaxContextId>;
diff --git a/crates/span/src/map.rs b/crates/span/src/map.rs
index 6269f4c30c..c539754979 100644
--- a/crates/span/src/map.rs
+++ b/crates/span/src/map.rs
@@ -119,7 +119,7 @@ impl fmt::Display for RealSpanMap {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "RealSpanMap({:?}):", self.file_id)?;
for span in self.pairs.iter() {
- writeln!(f, "{}: {}", u32::from(span.0), span.1.into_raw().into_u32())?;
+ writeln!(f, "{}: {}", u32::from(span.0), span.1.into_raw())?;
}
Ok(())
}
diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs
index e1f40f5da0..03e85a898a 100644
--- a/crates/test-fixture/src/lib.rs
+++ b/crates/test-fixture/src/lib.rs
@@ -3,7 +3,7 @@ use std::{iter, mem, str::FromStr, sync};
use base_db::{
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Env, FileChange,
- FileSet, LangCrateOrigin, SourceDatabaseExt, SourceRoot, Version, VfsPath,
+ FileSet, LangCrateOrigin, SourceRoot, SourceRootDatabase, Version, VfsPath,
};
use cfg::CfgOptions;
use hir_expand::{
@@ -26,7 +26,7 @@ use tt::{Leaf, Subtree, TokenTree};
pub const WORKSPACE: base_db::SourceRootId = base_db::SourceRootId(0);
-pub trait WithFixture: Default + ExpandDatabase + SourceDatabaseExt + 'static {
+pub trait WithFixture: Default + ExpandDatabase + SourceRootDatabase + 'static {
#[track_caller]
fn with_single_file(ra_fixture: &str) -> (Self, EditionedFileId) {
let fixture = ChangeFixture::parse(ra_fixture);
@@ -101,7 +101,7 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabaseExt + 'static {
}
}
-impl<DB: ExpandDatabase + SourceDatabaseExt + Default + 'static> WithFixture for DB {}
+impl<DB: ExpandDatabase + SourceRootDatabase + Default + 'static> WithFixture for DB {}
pub struct ChangeFixture {
pub file_position: Option<(EditionedFileId, RangeOrOffset)>,