File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,9 +25,17 @@ pub trait Db: SemanticDb + Upcast<dyn SemanticDb> {
2525#[ derive( Clone ) ]
2626pub struct ProjectDatabase {
2727 project : Option < Project > ,
28- storage : salsa:: Storage < ProjectDatabase > ,
2928 files : Files ,
29+
30+ // IMPORTANT: Never return clones of `system` outside `ProjectDatabase` (only return references)
31+ // or the "trick" to get a mutable `Arc` in `Self::system_mut` is no longer guaranteed to work.
3032 system : Arc < dyn System + Send + Sync + RefUnwindSafe > ,
33+
34+ // IMPORTANT: This field must be the last because we use `zalsa_mut` (drops all other storage references)
35+ // to drop all other references to the database, which gives us exclusive access to other `Arc`s stored on this db.
36+ // However, for this to work it's important that the `storage` is dropped AFTER any `Arc` that
37+ // we try to mutably borrow using `Arc::get_mut` (like `system`).
38+ storage : salsa:: Storage < ProjectDatabase > ,
3139}
3240
3341impl ProjectDatabase {
You can’t perform that action at this time.
0 commit comments