Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/unlinked_file.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/unlinked_file.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
index f3109b9bb7..550751b6c0 100644
--- a/crates/ide-diagnostics/src/handlers/unlinked_file.rs
+++ b/crates/ide-diagnostics/src/handlers/unlinked_file.rs
@@ -3,9 +3,10 @@
use std::iter;
use hir::{db::DefDatabase, DefMap, InFile, ModuleSource};
+use ide_db::base_db::RootQueryDb;
use ide_db::text_edit::TextEdit;
use ide_db::{
- base_db::{FileLoader, SourceDatabase, SourceRootDatabase},
+ base_db::{SourceDatabase, Upcast},
source_change::SourceChange,
FileId, FileRange, LineIndexDatabase,
};
@@ -48,6 +49,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 = SourceDatabase::file_text(ctx.sema.db, file_id)
+ .text(ctx.sema.db)
.char_indices()
.take(3)
.last()
@@ -78,7 +80,11 @@ fn fixes(
// If there's an existing module that could add `mod` or `pub mod` items to include the unlinked file,
// suggest that as a fix.
- let source_root = ctx.sema.db.source_root(ctx.sema.db.file_source_root(file_id));
+ let db = ctx.sema.db;
+
+ let source_root = ctx.sema.db.file_source_root(file_id).source_root_id(db);
+ let source_root = ctx.sema.db.source_root(source_root).source_root(db);
+
let our_path = source_root.path_for_file(&file_id)?;
let parent = our_path.parent()?;
let (module_name, _) = our_path.name_and_extension()?;
@@ -93,7 +99,8 @@ fn fixes(
};
// check crate roots, i.e. main.rs, lib.rs, ...
- 'crates: for &krate in &*ctx.sema.db.relevant_crates(file_id) {
+ let relevant_crates = Upcast::<dyn RootQueryDb>::upcast(db).relevant_crates(file_id);
+ 'crates: for &krate in &*relevant_crates {
let crate_def_map = ctx.sema.db.crate_def_map(krate);
let root_module = &crate_def_map[DefMap::ROOT];
@@ -141,7 +148,8 @@ fn fixes(
paths.into_iter().find_map(|path| source_root.file_for_path(&path))
})?;
stack.pop();
- 'crates: for &krate in ctx.sema.db.relevant_crates(parent_id).iter() {
+ let relevant_crates = Upcast::<dyn RootQueryDb>::upcast(db).relevant_crates(parent_id);
+ 'crates: for &krate in relevant_crates.iter() {
let crate_def_map = ctx.sema.db.crate_def_map(krate);
let Some((_, module)) = crate_def_map.modules().find(|(_, module)| {
module.origin.file_id().map(Into::into) == Some(parent_id) && !module.origin.is_inline()