Repository: rust-analyzer/rust-analyzer
Pull request #6785 (2020-12-09 16:31:47)

Fix "no value set for FileTextQuery(FileId(..))"
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6622

Let's hope I got it right this time, but I feel like I slowly begin to understand the main loop logic.

bors r+


Patch:
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs
index 595f28adae..5571af4954 100644
--- a/crates/base_db/src/lib.rs
+++ b/crates/base_db/src/lib.rs
@@ -18,7 +18,7 @@ pub use crate::{
     },
 };
 pub use salsa;
-pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, FileId, VfsPath};
+pub use vfs::{file_set::FileSet, FileId, VfsPath};
 
 #[macro_export]
 macro_rules! impl_intern_key {
@@ -91,7 +91,12 @@ pub const DEFAULT_LRU_CAP: usize = 128;
 pub trait FileLoader {
     /// Text of the file.
     fn file_text(&self, file_id: FileId) -> Arc<String>;
-    fn resolve_path(&self, path: AnchoredPath) -> Option<FileId>;
+    /// Note that we intentionally accept a `&str` and not a `&Path` here. This
+    /// method exists to handle `#[path = "/some/path.rs"] mod foo;` and such,
+    /// so the input is guaranteed to be utf-8 string. One might be tempted to
+    /// introduce some kind of "utf-8 path with / separators", but that's a bad idea. Behold
+    /// `#[path = "C://no/way"]`
+    fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>;
     fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>;
 }
 
@@ -150,11 +155,11 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
     fn file_text(&self, file_id: FileId) -> Arc<String> {
         SourceDatabaseExt::file_text(self.0, file_id)
     }
-    fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
+    fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
         // FIXME: this *somehow* should be platform agnostic...
-        let source_root = self.0.file_source_root(path.anchor);
+        let source_root = self.0.file_source_root(anchor);
         let source_root = self.0.source_root(source_root);
-        source_root.file_set.resolve_path(path)
+        source_root.file_set.resolve_path(anchor, path)
     }
 
     fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs
index b4ccd4488b..c0c789caef 100644
--- a/crates/hir_def/src/nameres/mod_resolution.rs
+++ b/crates/hir_def/src/nameres/mod_resolution.rs
@@ -1,5 +1,5 @@
 //! This module resolves `mod foo;` declaration to file.
-use base_db::{AnchoredPath, FileId};
+use base_db::FileId;
 use hir_expand::name::Name;
 use syntax::SmolStr;
 use test_utils::mark;
@@ -77,8 +77,7 @@ impl ModDir {
         };
 
         for candidate in candidate_files.iter() {
-            let path = AnchoredPath { anchor: file_id, path: candidate.as_str() };
-            if let Some(file_id) = db.resolve_path(path) {
+            if let Some(file_id) = db.resolve_path(file_id, candidate.as_str()) {
                 let is_mod_rs = candidate.ends_with("mod.rs");
 
                 let (dir_path, root_non_dir_owner) = if is_mod_rs || attr_path.is_some() {
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index f60666a54a..79b9708504 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -4,7 +4,7 @@ use crate::{
     MacroDefId, MacroDefKind, TextSize,
 };
 
-use base_db::{AnchoredPath, FileId};
+use base_db::FileId;
 use either::Either;
 use mbe::{parse_to_token_tree, ExpandResult};
 use parser::FragmentKind;
@@ -324,8 +324,7 @@ fn relative_file(
     allow_recursion: bool,
 ) -> Option<FileId> {
     let call_site = call_id.as_file().original_file(db);
-    let path = AnchoredPath { anchor: call_site, path };
-    let res = db.resolve_path(path)?;
+    let res = db.resolve_path(call_site, path)?;
     // Prevent include itself
     if res == call_site && !allow_recursion {
         None
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs
index d09f3a0a1f..c8453edb30 100644
--- a/crates/ide/src/diagnostics.rs
+++ b/crates/ide/src/diagnostics.rs
@@ -610,12 +610,10 @@ fn test_fn() {
                                     source_file_edits: [],
                                     file_system_edits: [
                                         CreateFile {
-                                            dst: AnchoredPathBuf {
-                                                anchor: FileId(
-                                                    0,
-                                                ),
-                                                path: "foo.rs",
-                                            },
+                                            anchor: FileId(
+                                                0,
+                                            ),
+                                            dst: "foo.rs",
                                         },
                                     ],
                                     is_snippet: false,
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs
index 29c7a040b6..24d08651e1 100644
--- a/crates/ide/src/diagnostics/fixes.rs
+++ b/crates/ide/src/diagnostics/fixes.rs
@@ -8,7 +8,7 @@ use hir::{
     },
     HasSource, HirDisplay, Semantics, VariantDef,
 };
-use ide_db::base_db::{AnchoredPathBuf, FileId};
+use ide_db::base_db::FileId;
 use ide_db::{
     source_change::{FileSystemEdit, SourceFileEdit},
     RootDatabase,
@@ -36,10 +36,8 @@ impl DiagnosticWithFix for UnresolvedModule {
         Some(Fix::new(
             "Create module",
             FileSystemEdit::CreateFile {
-                dst: AnchoredPathBuf {
-                    anchor: self.file.original_file(sema.db),
-                    path: self.candidate.clone(),
-                },
+                anchor: self.file.original_file(sema.db),
+                dst: self.candidate.clone(),
             }
             .into(),
             unresolved_module.syntax().text_range(),
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs
index 44081f2100..64fe8bd654 100644
--- a/crates/ide/src/references/rename.rs
+++ b/crates/ide/src/references/rename.rs
@@ -6,7 +6,7 @@ use std::{
 };
 
 use hir::{Module, ModuleDef, ModuleSource, Semantics};
-use ide_db::base_db::{AnchoredPathBuf, FileRange, SourceDatabaseExt};
+use ide_db::base_db::{FileRange, SourceDatabaseExt};
 use ide_db::{
     defs::{Definition, NameClass, NameRefClass},
     RootDatabase,
@@ -182,13 +182,12 @@ fn rename_mod(
     match src.value {
         ModuleSource::SourceFile(..) => {
             // mod is defined in path/to/dir/mod.rs
-            let path = if module.is_mod_rs(sema.db) {
+            let dst = if module.is_mod_rs(sema.db) {
                 format!("../{}/mod.rs", new_name)
             } else {
                 format!("{}.rs", new_name)
             };
-            let dst = AnchoredPathBuf { anchor: file_id, path };
-            let move_file = FileSystemEdit::MoveFile { src: file_id, dst };
+            let move_file = FileSystemEdit::MoveFile { src: file_id, anchor: file_id, dst };
             file_system_edits.push(move_file);
         }
         ModuleSource::Module(..) => {}
@@ -772,12 +771,10 @@ mod foo<|>;
                                 src: FileId(
                                     2,
                                 ),
-                                dst: AnchoredPathBuf {
-                                    anchor: FileId(
-                                        2,
-                                    ),
-                                    path: "foo2.rs",
-                                },
+                                anchor: FileId(
+                                    2,
+                                ),
+                                dst: "foo2.rs",
                             },
                         ],
                         is_snippet: false,
@@ -840,12 +837,10 @@ use crate::foo<|>::FooContent;
                                 src: FileId(
                                     1,
                                 ),
-                                dst: AnchoredPathBuf {
-                                    anchor: FileId(
-                                        1,
-                                    ),
-                                    path: "quux.rs",
-                                },
+                                anchor: FileId(
+                                    1,
+                                ),
+                                dst: "quux.rs",
                             },
                         ],
                         is_snippet: false,
@@ -889,12 +884,10 @@ mod fo<|>o;
                                 src: FileId(
                                     1,
                                 ),
-                                dst: AnchoredPathBuf {
-                                    anchor: FileId(
-                                        1,
-                                    ),
-                                    path: "../foo2/mod.rs",
-                                },
+                                anchor: FileId(
+                                    1,
+                                ),
+                                dst: "../foo2/mod.rs",
                             },
                         ],
                         is_snippet: false,
@@ -939,12 +932,10 @@ mod outer { mod fo<|>o; }
                                 src: FileId(
                                     1,
                                 ),
-                                dst: AnchoredPathBuf {
-                                    anchor: FileId(
-                                        1,
-                                    ),
-                                    path: "bar.rs",
-                                },
+                                anchor: FileId(
+                                    1,
+                                ),
+                                dst: "bar.rs",
                             },
                         ],
                         is_snippet: false,
@@ -1025,12 +1016,10 @@ pub mod foo<|>;
                                 src: FileId(
                                     2,
                                 ),
-                                dst: AnchoredPathBuf {
-                                    anchor: FileId(
-                                        2,
-                                    ),
-                                    path: "foo2.rs",
-                                },
+                                anchor: FileId(
+                                    2,
+                                ),
+                                dst: "foo2.rs",
                             },
                         ],
                         is_snippet: false,
diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs
index 118c090d75..fceaa089ad 100644
--- a/crates/ide_db/src/lib.rs
+++ b/crates/ide_db/src/lib.rs
@@ -19,8 +19,8 @@ use std::{fmt, sync::Arc};
 
 use base_db::{
     salsa::{self, Durability},
-    AnchoredPath, Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate,
-    SourceDatabase, Upcast,
+    Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase,
+    Upcast,
 };
 use hir::db::{AstDatabase, DefDatabase, HirDatabase};
 use rustc_hash::FxHashSet;
@@ -72,8 +72,8 @@ impl FileLoader for RootDatabase {
     fn file_text(&self, file_id: FileId) -> Arc<String> {
         FileLoaderDelegate(self).file_text(file_id)
     }
-    fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
-        FileLoaderDelegate(self).resolve_path(path)
+    fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
+        FileLoaderDelegate(self).resolve_path(anchor, path)
     }
     fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
         FileLoaderDelegate(self).relevant_crates(file_id)
diff --git a/crates/ide_db/src/source_change.rs b/crates/ide_db/src/source_change.rs
index e87d98dadc..f1590ec663 100644
--- a/crates/ide_db/src/source_change.rs
+++ b/crates/ide_db/src/source_change.rs
@@ -3,7 +3,7 @@
 //!
 //! It can be viewed as a dual for `AnalysisChange`.
 
-use base_db::{AnchoredPathBuf, FileId};
+use base_db::FileId;
 use text_edit::TextEdit;
 
 #[derive(Default, Debug, Clone)]
@@ -44,8 +44,8 @@ impl From<Vec<SourceFileEdit>> for SourceChange {
 
 #[derive(Debug, Clone)]
 pub enum FileSystemEdit {
-    CreateFile { dst: AnchoredPathBuf },
-    MoveFile { src: FileId, dst: AnchoredPathBuf },
+    CreateFile { anchor: FileId, dst: String },
+    MoveFile { src: FileId, anchor: FileId, dst: String },
 }
 
 impl From<FileSystemEdit> for SourceChange {
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index d51f4a93ad..e5ab6c73bb 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -73,7 +73,7 @@ fn load(
             }
             vfs::loader::Message::Loaded { files } => {
                 for (path, contents) in files {
-                    vfs.set_file_contents(path.into(), contents)
+                    vfs.set_file_contents(path.into(), contents);
                 }
             }
         }
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index 71dc569157..a27495d0d8 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -13,7 +13,6 @@ use lsp_types::{SemanticTokens, Url};
 use parking_lot::{Mutex, RwLock};
 use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
 use rustc_hash::FxHashMap;
-use vfs::AnchoredPathBuf;
 
 use crate::{
     config::Config,
@@ -269,10 +268,10 @@ impl GlobalStateSnapshot {
         Some(self.mem_docs.get(&path)?.version)
     }
 
-    pub(crate) fn anchored_path(&self, path: &AnchoredPathBuf) -> Url {
-        let mut base = self.vfs.read().0.file_path(path.anchor);
+    pub(crate) fn anchored_path(&self, file_id: FileId, path: &str) -> Url {
+        let mut base = self.vfs.read().0.file_path(file_id);
         base.pop();
-        let path = base.join(&path.path).unwrap();
+        let path = base.join(path).unwrap();
         let path = path.as_path().unwrap();
         url_from_abs_path(&path)
     }
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 95be2ebd39..d7f8374af7 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -255,7 +255,7 @@ impl GlobalState {
                             for (path, contents) in files {
                                 let path = VfsPath::from(path);
                                 if !self.mem_docs.contains_key(&path) {
-                                    vfs.set_file_contents(path, contents)
+                                    vfs.set_file_contents(path, contents);
                                 }
                             }
                         }
@@ -503,11 +503,21 @@ impl GlobalState {
                     {
                         log::error!("duplicate DidOpenTextDocument: {}", path)
                     }
-                    this.vfs
+                    let changed = this
+                        .vfs
                         .write()
                         .0
                         .set_file_contents(path, Some(params.text_document.text.into_bytes()));
-                    this.maybe_update_diagnostics();
+
+                    // If the VFS contents are unchanged, update diagnostics, since `handle_event`
+                    // won't see any changes. This avoids missing diagnostics when opening a file.
+                    //
+                    // If the file *was* changed, `handle_event` will already recompute and send
+                    // diagnostics. We can't do it here, since the *current* file contents might be
+                    // unset in salsa, since the VFS change hasn't been applied to the database yet.
+                    if !changed {
+                        this.maybe_update_diagnostics();
+                    }
                 }
                 Ok(())
             })?
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 715f8927a5..01eabe8526 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -628,17 +628,17 @@ pub(crate) fn resource_op(
     file_system_edit: FileSystemEdit,
 ) -> lsp_types::ResourceOp {
     match file_system_edit {
-        FileSystemEdit::CreateFile { dst } => {
-            let uri = snap.anchored_path(&dst);
+        FileSystemEdit::CreateFile { anchor, dst } => {
+            let uri = snap.anchored_path(anchor, &dst);
             lsp_types::ResourceOp::Create(lsp_types::CreateFile {
                 uri,
                 options: None,
                 annotation: None,
             })
         }
-        FileSystemEdit::MoveFile { src, dst } => {
+        FileSystemEdit::MoveFile { src, anchor, dst } => {
             let old_uri = snap.file_id_to_url(src);
-            let new_uri = snap.anchored_path(&dst);
+            let new_uri = snap.anchored_path(anchor, &dst);
             lsp_types::ResourceOp::Rename(lsp_types::RenameFile {
                 old_uri,
                 new_uri,
diff --git a/crates/vfs/src/anchored_path.rs b/crates/vfs/src/anchored_path.rs
deleted file mode 100644
index 02720a32e3..0000000000
--- a/crates/vfs/src/anchored_path.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-//! Analysis-level representation of file-system paths.
-//!
-//! The primary goal of this is to losslessly represent paths like
-//!
-//! ```
-//! #[path = "./bar.rs"]
-//! mod foo;
-//! ```
-//!
-//! The first approach one might reach for is to use `PathBuf`. The problem here
-//! is that `PathBuf` depends on host target (windows or linux), but
-//! rust-analyzer should be capable to process `#[path = r"C:\bar.rs"]` on Unix.
-//!
-//! The second try is to use a `String`. This also fails, however. Consider a
-//! hypothetical scenario, where rust-analyzer operates in a
-//! networked/distributed mode. There's one global instance of rust-analyzer,
-//! which processes requests from different machines. Now, the semantics of
-//! `#[path = "/abs/path.rs"]` actually depends on which file-system we are at!
-//! That is, even absolute paths exist relative to a file system!
-//!
-//! A more realistic scenario here is virtual VFS paths we use for testing. More
-//! generally, there can be separate "universes" of VFS paths.
-//!
-//! That's why we use anchored representation -- each path carries an info about
-//! a file this path originates from. We can fetch fs/"universe" information
-//! from the anchor than.
-use crate::FileId;
-
-#[derive(Clone, PartialEq, Eq, Debug)]
-pub struct AnchoredPathBuf {
-    pub anchor: FileId,
-    pub path: String,
-}
-
-#[derive(Clone, Copy, PartialEq, Eq, Debug)]
-pub struct AnchoredPath<'a> {
-    pub anchor: FileId,
-    pub path: &'a str,
-}
diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs
index 49ca593ac8..9093fbd979 100644
--- a/crates/vfs/src/file_set.rs
+++ b/crates/vfs/src/file_set.rs
@@ -7,7 +7,7 @@ use std::fmt;
 use fst::{IntoStreamer, Streamer};
 use rustc_hash::FxHashMap;
 
-use crate::{AnchoredPath, FileId, Vfs, VfsPath};
+use crate::{FileId, Vfs, VfsPath};
 
 #[derive(Default, Clone, Eq, PartialEq)]
 pub struct FileSet {
@@ -19,10 +19,10 @@ impl FileSet {
     pub fn len(&self) -> usize {
         self.files.len()
     }
-    pub fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
-        let mut base = self.paths[&path.anchor].clone();
+    pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
+        let mut base = self.paths[&anchor].clone();
         base.pop();
-        let path = base.join(path.path)?;
+        let path = base.join(path)?;
         self.files.get(&path).copied()
     }
 
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index a3be579a71..a2c6a34000 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -36,7 +36,6 @@
 //! have a single `FileSet` which unions the two sources.
 mod vfs_path;
 mod path_interner;
-mod anchored_path;
 pub mod file_set;
 pub mod loader;
 
@@ -44,10 +43,7 @@ use std::{fmt, mem};
 
 use crate::path_interner::PathInterner;
 
-pub use crate::{
-    anchored_path::{AnchoredPath, AnchoredPathBuf},
-    vfs_path::VfsPath,
-};
+pub use crate::vfs_path::VfsPath;
 pub use paths::{AbsPath, AbsPathBuf};
 
 #[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
@@ -103,18 +99,19 @@ impl Vfs {
                 (file_id, path)
             })
     }
-    pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) {
+    pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) -> bool {
         let file_id = self.alloc_file_id(path);
         let change_kind = match (&self.get(file_id), &contents) {
-            (None, None) => return,
+            (None, None) => return false,
             (None, Some(_)) => ChangeKind::Create,
             (Some(_), None) => ChangeKind::Delete,
-            (Some(old), Some(new)) if old == new => return,
+            (Some(old), Some(new)) if old == new => return false,
             (Some(_), Some(_)) => ChangeKind::Modify,
         };
 
         *self.get_mut(file_id) = contents;
-        self.changes.push(ChangedFile { file_id, change_kind })
+        self.changes.push(ChangedFile { file_id, change_kind });
+        true
     }
     pub fn has_changes(&self) -> bool {
         !self.changes.is_empty()


Test patch:
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs
index 574c0201a7..f8b1508508 100644
--- a/crates/hir_def/src/test_db.rs
+++ b/crates/hir_def/src/test_db.rs
@@ -5,8 +5,8 @@ use std::{
     sync::{Arc, Mutex},
 };
 
+use base_db::SourceDatabase;
 use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast};
-use base_db::{AnchoredPath, SourceDatabase};
 use hir_expand::db::AstDatabase;
 use hir_expand::diagnostics::Diagnostic;
 use hir_expand::diagnostics::DiagnosticSinkBuilder;
@@ -63,8 +63,8 @@ impl FileLoader for TestDB {
     fn file_text(&self, file_id: FileId) -> Arc<String> {
         FileLoaderDelegate(self).file_text(file_id)
     }
-    fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
-        FileLoaderDelegate(self).resolve_path(path)
+    fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
+        FileLoaderDelegate(self).resolve_path(anchor, path)
     }
     fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
         FileLoaderDelegate(self).relevant_crates(file_id)
diff --git a/crates/hir_expand/src/test_db.rs b/crates/hir_expand/src/test_db.rs
index 7168a94624..fca501e1f2 100644
--- a/crates/hir_expand/src/test_db.rs
+++ b/crates/hir_expand/src/test_db.rs
@@ -5,7 +5,7 @@ use std::{
     sync::{Arc, Mutex},
 };
 
-use base_db::{salsa, AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate};
+use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate};
 use rustc_hash::FxHashSet;
 
 #[salsa::database(
@@ -40,8 +40,8 @@ impl FileLoader for TestDB {
     fn file_text(&self, file_id: FileId) -> Arc<String> {
         FileLoaderDelegate(self).file_text(file_id)
     }
-    fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
-        FileLoaderDelegate(self).resolve_path(path)
+    fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
+        FileLoaderDelegate(self).resolve_path(anchor, path)
     }
     fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
         FileLoaderDelegate(self).relevant_crates(file_id)
diff --git a/crates/hir_ty/src/test_db.rs b/crates/hir_ty/src/test_db.rs
index 646e16bbec..22254b7659 100644
--- a/crates/hir_ty/src/test_db.rs
+++ b/crates/hir_ty/src/test_db.rs
@@ -5,9 +5,7 @@ use std::{
     sync::{Arc, Mutex},
 };
 
-use base_db::{
-    salsa, AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
-};
+use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast};
 use hir_def::{db::DefDatabase, ModuleId};
 use hir_expand::db::AstDatabase;
 use rustc_hash::{FxHashMap, FxHashSet};
@@ -69,8 +67,8 @@ impl FileLoader for TestDB {
     fn file_text(&self, file_id: FileId) -> Arc<String> {
         FileLoaderDelegate(self).file_text(file_id)
     }
-    fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
-        FileLoaderDelegate(self).resolve_path(path)
+    fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
+        FileLoaderDelegate(self).resolve_path(anchor, path)
     }
     fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {
         FileLoaderDelegate(self).relevant_crates(file_id)