diff options
-rw-r--r-- | Cargo.lock | 24 | ||||
-rw-r--r-- | crates/ra_analysis/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/db.rs | 14 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 60 |
4 files changed, 55 insertions, 45 deletions
diff --git a/Cargo.lock b/Cargo.lock index bf937d205..fd1fb5ea5 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -268,7 +268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
268 | dependencies = [ | 268 | dependencies = [ |
269 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", | 269 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", |
270 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", | 270 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", |
271 | "syn 0.15.16 (registry+https://github.com/rust-lang/crates.io-index)", | 271 | "syn 0.15.17 (registry+https://github.com/rust-lang/crates.io-index)", |
272 | "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", | 272 | "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", |
273 | ] | 273 | ] |
274 | 274 | ||
@@ -484,7 +484,7 @@ dependencies = [ | |||
484 | "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | 484 | "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", |
485 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", | 485 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", |
486 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", | 486 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", |
487 | "syn 0.15.16 (registry+https://github.com/rust-lang/crates.io-index)", | 487 | "syn 0.15.17 (registry+https://github.com/rust-lang/crates.io-index)", |
488 | ] | 488 | ] |
489 | 489 | ||
490 | [[package]] | 490 | [[package]] |
@@ -608,7 +608,7 @@ dependencies = [ | |||
608 | "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 608 | "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
609 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 609 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
610 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 610 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
611 | "salsa 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", | 611 | "salsa 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
612 | "test_utils 0.1.0", | 612 | "test_utils 0.1.0", |
613 | ] | 613 | ] |
614 | 614 | ||
@@ -836,7 +836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
836 | 836 | ||
837 | [[package]] | 837 | [[package]] |
838 | name = "salsa" | 838 | name = "salsa" |
839 | version = "0.7.0" | 839 | version = "0.8.0" |
840 | source = "registry+https://github.com/rust-lang/crates.io-index" | 840 | source = "registry+https://github.com/rust-lang/crates.io-index" |
841 | dependencies = [ | 841 | dependencies = [ |
842 | "derive-new 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", | 842 | "derive-new 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -890,7 +890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
890 | dependencies = [ | 890 | dependencies = [ |
891 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", | 891 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", |
892 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", | 892 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", |
893 | "syn 0.15.16 (registry+https://github.com/rust-lang/crates.io-index)", | 893 | "syn 0.15.17 (registry+https://github.com/rust-lang/crates.io-index)", |
894 | ] | 894 | ] |
895 | 895 | ||
896 | [[package]] | 896 | [[package]] |
@@ -965,7 +965,7 @@ dependencies = [ | |||
965 | 965 | ||
966 | [[package]] | 966 | [[package]] |
967 | name = "syn" | 967 | name = "syn" |
968 | version = "0.15.16" | 968 | version = "0.15.17" |
969 | source = "registry+https://github.com/rust-lang/crates.io-index" | 969 | source = "registry+https://github.com/rust-lang/crates.io-index" |
970 | dependencies = [ | 970 | dependencies = [ |
971 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", | 971 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -980,7 +980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
980 | dependencies = [ | 980 | dependencies = [ |
981 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", | 981 | "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", |
982 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", | 982 | "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", |
983 | "syn 0.15.16 (registry+https://github.com/rust-lang/crates.io-index)", | 983 | "syn 0.15.17 (registry+https://github.com/rust-lang/crates.io-index)", |
984 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 984 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
985 | ] | 985 | ] |
986 | 986 | ||
@@ -995,7 +995,7 @@ dependencies = [ | |||
995 | 995 | ||
996 | [[package]] | 996 | [[package]] |
997 | name = "tera" | 997 | name = "tera" |
998 | version = "0.11.18" | 998 | version = "0.11.19" |
999 | source = "registry+https://github.com/rust-lang/crates.io-index" | 999 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1000 | dependencies = [ | 1000 | dependencies = [ |
1001 | "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1001 | "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1021,7 +1021,7 @@ dependencies = [ | |||
1021 | "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1021 | "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1022 | "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1022 | "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1023 | "ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1023 | "ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1024 | "tera 0.11.18 (registry+https://github.com/rust-lang/crates.io-index)", | 1024 | "tera 0.11.19 (registry+https://github.com/rust-lang/crates.io-index)", |
1025 | ] | 1025 | ] |
1026 | 1026 | ||
1027 | [[package]] | 1027 | [[package]] |
@@ -1352,7 +1352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1352 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1352 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
1353 | "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" | 1353 | "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" |
1354 | "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" | 1354 | "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" |
1355 | "checksum salsa 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef0f1fb2a01d4579b6658343b1b5431a72c62c186ebb9b40bd6cd3078c7afecf" | 1355 | "checksum salsa 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e56b13ce9b2bfaa1c89863d76880838c0734de85beeaef437fd70d4fa7e253d3" |
1356 | "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" | 1356 | "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" |
1357 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" | 1357 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" |
1358 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | 1358 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" |
@@ -1368,10 +1368,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1368 | "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" | 1368 | "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" |
1369 | "checksum superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b50b13d42370e0f5fc62eafdd5c2d20065eaf5458dab215ff3e20e63eea96b30" | 1369 | "checksum superslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b50b13d42370e0f5fc62eafdd5c2d20065eaf5458dab215ff3e20e63eea96b30" |
1370 | "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" | 1370 | "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" |
1371 | "checksum syn 0.15.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0b78d53b5e1b6e63129140b1336877c3bddbae398c7956150396bdad0e28676c" | 1371 | "checksum syn 0.15.17 (registry+https://github.com/rust-lang/crates.io-index)" = "3391038ebc3e4ab24eb028cb0ef2f2dc4ba0cbf72ee895ed6a6fad730640b5bc" |
1372 | "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" | 1372 | "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" |
1373 | "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" | 1373 | "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" |
1374 | "checksum tera 0.11.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6c87cae42cc4fc480278c7583792cc5da2d51a25be916b7921cbb45c43063b8d" | 1374 | "checksum tera 0.11.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac6d8ad623a7efcfb4367ce2a36f84ef849d5aa3c7bcf2e0324c4cbcc57ebaf" |
1375 | "checksum teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d89ad4617d1dec55331067fadaa041e813479e1779616f3d3ce9308bf46184e" | 1375 | "checksum teraron 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d89ad4617d1dec55331067fadaa041e813479e1779616f3d3ce9308bf46184e" |
1376 | "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" | 1376 | "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" |
1377 | "checksum text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8009d7bdbd896a7e09b595f8f9325a19047fc708653e60d0895202b82135048f" | 1377 | "checksum text_unit 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8009d7bdbd896a7e09b595f8f9325a19047fc708653e60d0895202b82135048f" |
diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_analysis/Cargo.toml index deddf41f0..908ee1c81 100644 --- a/crates/ra_analysis/Cargo.toml +++ b/crates/ra_analysis/Cargo.toml | |||
@@ -9,7 +9,7 @@ log = "0.4.5" | |||
9 | relative-path = "0.4.0" | 9 | relative-path = "0.4.0" |
10 | rayon = "1.0.2" | 10 | rayon = "1.0.2" |
11 | fst = "0.3.1" | 11 | fst = "0.3.1" |
12 | salsa = "0.7.0" | 12 | salsa = "0.8.0" |
13 | rustc-hash = "1.0" | 13 | rustc-hash = "1.0" |
14 | ra_syntax = { path = "../ra_syntax" } | 14 | ra_syntax = { path = "../ra_syntax" } |
15 | ra_editor = { path = "../ra_editor" } | 15 | ra_editor = { path = "../ra_editor" } |
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index 94fdd36a4..9548ec602 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -35,16 +35,10 @@ pub(crate) fn check_canceled(db: &impl salsa::Database) -> Cancelable<()> { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | impl salsa::ParallelDatabase for RootDatabase { | 37 | impl salsa::ParallelDatabase for RootDatabase { |
38 | fn fork(&self) -> Self { | 38 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { |
39 | RootDatabase { | 39 | salsa::Snapshot::new(RootDatabase { |
40 | runtime: self.runtime.fork(), | 40 | runtime: self.runtime.snapshot(self), |
41 | } | 41 | }) |
42 | } | ||
43 | } | ||
44 | |||
45 | impl Clone for RootDatabase { | ||
46 | fn clone(&self) -> RootDatabase { | ||
47 | salsa::ParallelDatabase::fork(self) | ||
48 | } | 42 | } |
49 | } | 43 | } |
50 | 44 | ||
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 060e2b606..77dd71dcf 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | fmt, | ||
2 | hash::{Hash, Hasher}, | 3 | hash::{Hash, Hasher}, |
3 | sync::Arc, | 4 | sync::Arc, |
4 | }; | 5 | }; |
@@ -92,18 +93,18 @@ pub(crate) struct AnalysisHostImpl { | |||
92 | 93 | ||
93 | impl AnalysisHostImpl { | 94 | impl AnalysisHostImpl { |
94 | pub fn new() -> AnalysisHostImpl { | 95 | pub fn new() -> AnalysisHostImpl { |
95 | let db = db::RootDatabase::default(); | 96 | let mut db = db::RootDatabase::default(); |
96 | db.query(crate::input::SourceRootQuery) | 97 | db.query_mut(crate::input::SourceRootQuery) |
97 | .set(WORKSPACE, Default::default()); | 98 | .set(WORKSPACE, Default::default()); |
98 | db.query(crate::input::CrateGraphQuery) | 99 | db.query_mut(crate::input::CrateGraphQuery) |
99 | .set((), Default::default()); | 100 | .set((), Default::default()); |
100 | db.query(crate::input::LibrariesQuery) | 101 | db.query_mut(crate::input::LibrariesQuery) |
101 | .set((), Default::default()); | 102 | .set((), Default::default()); |
102 | AnalysisHostImpl { db } | 103 | AnalysisHostImpl { db } |
103 | } | 104 | } |
104 | pub fn analysis(&self) -> AnalysisImpl { | 105 | pub fn analysis(&self) -> AnalysisImpl { |
105 | AnalysisImpl { | 106 | AnalysisImpl { |
106 | db: self.db.fork(), // freeze revision here | 107 | db: self.db.snapshot(), |
107 | } | 108 | } |
108 | } | 109 | } |
109 | pub fn apply_change(&mut self, change: AnalysisChange) { | 110 | pub fn apply_change(&mut self, change: AnalysisChange) { |
@@ -111,7 +112,7 @@ impl AnalysisHostImpl { | |||
111 | 112 | ||
112 | for (file_id, text) in change.files_changed { | 113 | for (file_id, text) in change.files_changed { |
113 | self.db | 114 | self.db |
114 | .query(crate::input::FileTextQuery) | 115 | .query_mut(crate::input::FileTextQuery) |
115 | .set(file_id, Arc::new(text)) | 116 | .set(file_id, Arc::new(text)) |
116 | } | 117 | } |
117 | if !(change.files_added.is_empty() && change.files_removed.is_empty()) { | 118 | if !(change.files_added.is_empty() && change.files_removed.is_empty()) { |
@@ -121,22 +122,22 @@ impl AnalysisHostImpl { | |||
121 | let mut source_root = SourceRoot::clone(&self.db.source_root(WORKSPACE)); | 122 | let mut source_root = SourceRoot::clone(&self.db.source_root(WORKSPACE)); |
122 | for (file_id, text) in change.files_added { | 123 | for (file_id, text) in change.files_added { |
123 | self.db | 124 | self.db |
124 | .query(crate::input::FileTextQuery) | 125 | .query_mut(crate::input::FileTextQuery) |
125 | .set(file_id, Arc::new(text)); | 126 | .set(file_id, Arc::new(text)); |
126 | self.db | 127 | self.db |
127 | .query(crate::input::FileSourceRootQuery) | 128 | .query_mut(crate::input::FileSourceRootQuery) |
128 | .set(file_id, crate::input::WORKSPACE); | 129 | .set(file_id, crate::input::WORKSPACE); |
129 | source_root.files.insert(file_id); | 130 | source_root.files.insert(file_id); |
130 | } | 131 | } |
131 | for file_id in change.files_removed { | 132 | for file_id in change.files_removed { |
132 | self.db | 133 | self.db |
133 | .query(crate::input::FileTextQuery) | 134 | .query_mut(crate::input::FileTextQuery) |
134 | .set(file_id, Arc::new(String::new())); | 135 | .set(file_id, Arc::new(String::new())); |
135 | source_root.files.remove(&file_id); | 136 | source_root.files.remove(&file_id); |
136 | } | 137 | } |
137 | source_root.file_resolver = file_resolver; | 138 | source_root.file_resolver = file_resolver; |
138 | self.db | 139 | self.db |
139 | .query(crate::input::SourceRootQuery) | 140 | .query_mut(crate::input::SourceRootQuery) |
140 | .set(WORKSPACE, Arc::new(source_root)) | 141 | .set(WORKSPACE, Arc::new(source_root)) |
141 | } | 142 | } |
142 | if !change.libraries_added.is_empty() { | 143 | if !change.libraries_added.is_empty() { |
@@ -148,10 +149,10 @@ impl AnalysisHostImpl { | |||
148 | for (file_id, text) in library.files { | 149 | for (file_id, text) in library.files { |
149 | files.insert(file_id); | 150 | files.insert(file_id); |
150 | self.db | 151 | self.db |
151 | .query(crate::input::FileSourceRootQuery) | 152 | .query_mut(crate::input::FileSourceRootQuery) |
152 | .set_constant(file_id, source_root_id); | 153 | .set_constant(file_id, source_root_id); |
153 | self.db | 154 | self.db |
154 | .query(crate::input::FileTextQuery) | 155 | .query_mut(crate::input::FileTextQuery) |
155 | .set_constant(file_id, Arc::new(text)); | 156 | .set_constant(file_id, Arc::new(text)); |
156 | } | 157 | } |
157 | let source_root = SourceRoot { | 158 | let source_root = SourceRoot { |
@@ -159,27 +160,33 @@ impl AnalysisHostImpl { | |||
159 | file_resolver: library.file_resolver, | 160 | file_resolver: library.file_resolver, |
160 | }; | 161 | }; |
161 | self.db | 162 | self.db |
162 | .query(crate::input::SourceRootQuery) | 163 | .query_mut(crate::input::SourceRootQuery) |
163 | .set(source_root_id, Arc::new(source_root)); | 164 | .set(source_root_id, Arc::new(source_root)); |
164 | self.db | 165 | self.db |
165 | .query(crate::input::LibrarySymbolsQuery) | 166 | .query_mut(crate::input::LibrarySymbolsQuery) |
166 | .set(source_root_id, Arc::new(library.symbol_index)); | 167 | .set(source_root_id, Arc::new(library.symbol_index)); |
167 | } | 168 | } |
168 | self.db | 169 | self.db |
169 | .query(crate::input::LibrariesQuery) | 170 | .query_mut(crate::input::LibrariesQuery) |
170 | .set((), Arc::new(libraries)); | 171 | .set((), Arc::new(libraries)); |
171 | } | 172 | } |
172 | if let Some(crate_graph) = change.crate_graph { | 173 | if let Some(crate_graph) = change.crate_graph { |
173 | self.db | 174 | self.db |
174 | .query(crate::input::CrateGraphQuery) | 175 | .query_mut(crate::input::CrateGraphQuery) |
175 | .set((), Arc::new(crate_graph)) | 176 | .set((), Arc::new(crate_graph)) |
176 | } | 177 | } |
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
180 | #[derive(Debug)] | ||
181 | pub(crate) struct AnalysisImpl { | 181 | pub(crate) struct AnalysisImpl { |
182 | pub(crate) db: db::RootDatabase, | 182 | pub(crate) db: salsa::Snapshot<db::RootDatabase>, |
183 | } | ||
184 | |||
185 | impl fmt::Debug for AnalysisImpl { | ||
186 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | ||
187 | let db: &db::RootDatabase = &self.db; | ||
188 | fmt.debug_struct("AnalysisImpl").field("db", db).finish() | ||
189 | } | ||
183 | } | 190 | } |
184 | 191 | ||
185 | impl AnalysisImpl { | 192 | impl AnalysisImpl { |
@@ -198,10 +205,19 @@ impl AnalysisImpl { | |||
198 | .collect() | 205 | .collect() |
199 | } else { | 206 | } else { |
200 | let files = &self.db.source_root(WORKSPACE).files; | 207 | let files = &self.db.source_root(WORKSPACE).files; |
201 | let db = self.db.clone(); | 208 | |
209 | /// Need to wrap Snapshot to provide `Clon` impl for `map_with` | ||
210 | struct Snap(salsa::Snapshot<db::RootDatabase>); | ||
211 | impl Clone for Snap { | ||
212 | fn clone(&self) -> Snap { | ||
213 | Snap(self.0.snapshot()) | ||
214 | } | ||
215 | } | ||
216 | |||
217 | let snap = Snap(self.db.snapshot()); | ||
202 | files | 218 | files |
203 | .par_iter() | 219 | .par_iter() |
204 | .map_with(db, |db, &file_id| db.file_symbols(file_id)) | 220 | .map_with(snap, |db, &file_id| db.0.file_symbols(file_id)) |
205 | .filter_map(|it| it.ok()) | 221 | .filter_map(|it| it.ok()) |
206 | .collect() | 222 | .collect() |
207 | }; | 223 | }; |
@@ -229,7 +245,7 @@ impl AnalysisImpl { | |||
229 | return None; | 245 | return None; |
230 | } | 246 | } |
231 | }; | 247 | }; |
232 | let decl = link.bind_source(&module_tree, &self.db); | 248 | let decl = link.bind_source(&module_tree, &*self.db); |
233 | let decl = decl.ast(); | 249 | let decl = decl.ast(); |
234 | 250 | ||
235 | let sym = FileSymbol { | 251 | let sym = FileSymbol { |
@@ -371,7 +387,7 @@ impl AnalysisImpl { | |||
371 | }) | 387 | }) |
372 | .collect::<Vec<_>>(); | 388 | .collect::<Vec<_>>(); |
373 | if let Some(m) = module_tree.any_module_for_file(file_id) { | 389 | if let Some(m) = module_tree.any_module_for_file(file_id) { |
374 | for (name_node, problem) in m.problems(&module_tree, &self.db) { | 390 | for (name_node, problem) in m.problems(&module_tree, &*self.db) { |
375 | let diag = match problem { | 391 | let diag = match problem { |
376 | Problem::UnresolvedModule { candidate } => { | 392 | Problem::UnresolvedModule { candidate } => { |
377 | let create_file = FileSystemEdit::CreateFile { | 393 | let create_file = FileSystemEdit::CreateFile { |