Set durabilities for low-durability fields on high-durability inputs (#12627)

This commit is contained in:
Micha Reiser 2024-08-02 19:42:34 +02:00 committed by GitHub
parent dfb08856eb
commit 12177a42e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 50 additions and 51 deletions

View file

@ -37,10 +37,7 @@ impl FileRoot {
}
pub fn durability(self, db: &dyn Db) -> salsa::Durability {
match self.kind_at_time_of_creation(db) {
FileRootKind::Workspace => salsa::Durability::LOW,
FileRootKind::LibrarySearchPath => salsa::Durability::HIGH,
}
self.kind_at_time_of_creation(db).durability()
}
}
@ -53,6 +50,15 @@ pub enum FileRootKind {
LibrarySearchPath,
}
impl FileRootKind {
const fn durability(self) -> Durability {
match self {
FileRootKind::Workspace => Durability::LOW,
FileRootKind::LibrarySearchPath => Durability::HIGH,
}
}
}
#[derive(Default)]
pub(super) struct FileRoots {
by_path: matchit::Router<FileRoot>,
@ -86,6 +92,7 @@ impl FileRoots {
// Insert a new source root
let root = FileRoot::builder(path, kind, FileRevision::now())
.durability(Durability::HIGH)
.revision_durability(kind.durability())
.new(db);
// Insert a path that matches the root itself