mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-30 03:27:51 +00:00
Set durabilities for low-durability fields on high-durability inputs (#12627)
This commit is contained in:
parent
dfb08856eb
commit
12177a42e3
6 changed files with 50 additions and 51 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue