File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,17 @@ pub trait Db: SemanticDb + Upcast<dyn SemanticDb> {
25
25
#[ derive( Clone ) ]
26
26
pub struct ProjectDatabase {
27
27
project : Option < Project > ,
28
- storage : salsa:: Storage < ProjectDatabase > ,
29
28
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.
30
32
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 > ,
31
39
}
32
40
33
41
impl ProjectDatabase {
You can’t perform that action at this time.
0 commit comments