[red-knot] Upgrade to the *new* *new* salsa (#12406)

This commit is contained in:
Micha Reiser 2024-07-29 09:21:24 +02:00 committed by GitHub
parent 9495331a5f
commit e18b4e42d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 483 additions and 415 deletions

View file

@ -2,14 +2,16 @@ use std::sync::Arc;
use countme::Count;
use dashmap::mapref::entry::Entry;
use salsa::Setter;
pub use path::FilePath;
use ruff_notebook::{Notebook, NotebookError};
use crate::file_revision::FileRevision;
use crate::files::private::FileStatus;
use crate::system::{Metadata, SystemPath, SystemPathBuf, SystemVirtualPath, SystemVirtualPathBuf};
use crate::vendored::{VendoredPath, VendoredPathBuf};
use crate::{Db, FxDashMap};
pub use path::FilePath;
use ruff_notebook::{Notebook, NotebookError};
mod path;
@ -61,7 +63,7 @@ impl Files {
///
/// The operation always succeeds even if the path doesn't exist on disk, isn't accessible or if the path points to a directory.
/// In these cases, a file with status [`FileStatus::Deleted`] is returned.
#[tracing::instrument(level = "trace", skip(self, db), ret)]
#[tracing::instrument(level = "trace", skip(self, db))]
fn system(&self, db: &dyn Db, path: &SystemPath) -> File {
let absolute = SystemPath::absolute(path, db.system().current_directory());
@ -104,7 +106,7 @@ impl Files {
/// Looks up a vendored file by its path. Returns `Some` if a vendored file for the given path
/// exists and `None` otherwise.
#[tracing::instrument(level = "trace", skip(self, db), ret)]
#[tracing::instrument(level = "trace", skip(self, db))]
fn vendored(&self, db: &dyn Db, path: &VendoredPath) -> Option<File> {
let file = match self.inner.vendored_by_path.entry(path.to_path_buf()) {
Entry::Occupied(entry) => *entry.get(),
@ -196,14 +198,6 @@ impl Files {
file.sync(db);
}
}
/// Creates a salsa like snapshot. The instances share
/// the same path-to-file mapping.
pub fn snapshot(&self) -> Self {
Self {
inner: self.inner.clone(),
}
}
}
impl std::fmt::Debug for Files {
@ -221,7 +215,6 @@ impl std::fmt::Debug for Files {
#[salsa::input]
pub struct File {
/// The path of the file.
#[id]
#[return_ref]
pub path: FilePath,