mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +00:00
[ty] Fix server panic when calling system_mut
(#18252)
This commit is contained in:
parent
029085fa72
commit
98da200d45
1 changed files with 9 additions and 1 deletions
|
@ -25,9 +25,17 @@ pub trait Db: SemanticDb + Upcast<dyn SemanticDb> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ProjectDatabase {
|
pub struct ProjectDatabase {
|
||||||
project: Option<Project>,
|
project: Option<Project>,
|
||||||
storage: salsa::Storage<ProjectDatabase>,
|
|
||||||
files: Files,
|
files: Files,
|
||||||
|
|
||||||
|
// IMPORTANT: Never return clones of `system` outside `ProjectDatabase` (only return references)
|
||||||
|
// or the "trick" to get a mutable `Arc` in `Self::system_mut` is no longer guaranteed to work.
|
||||||
system: Arc<dyn System + Send + Sync + RefUnwindSafe>,
|
system: Arc<dyn System + Send + Sync + RefUnwindSafe>,
|
||||||
|
|
||||||
|
// IMPORTANT: This field must be the last because we use `zalsa_mut` (drops all other storage references)
|
||||||
|
// to drop all other references to the database, which gives us exclusive access to other `Arc`s stored on this db.
|
||||||
|
// However, for this to work it's important that the `storage` is dropped AFTER any `Arc` that
|
||||||
|
// we try to mutably borrow using `Arc::get_mut` (like `system`).
|
||||||
|
storage: salsa::Storage<ProjectDatabase>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProjectDatabase {
|
impl ProjectDatabase {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue