aboutsummaryrefslogtreecommitdiff
path: root/crates/libanalysis/src/db/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libanalysis/src/db/mod.rs')
-rw-r--r--crates/libanalysis/src/db/mod.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/crates/libanalysis/src/db/mod.rs b/crates/libanalysis/src/db/mod.rs
index f68aab61c..3198272b7 100644
--- a/crates/libanalysis/src/db/mod.rs
+++ b/crates/libanalysis/src/db/mod.rs
@@ -120,38 +120,36 @@ impl<'a> QueryCtx<'a> {
120 120
121fn query_config() -> salsa::QueryConfig<State, Data> { 121fn query_config() -> salsa::QueryConfig<State, Data> {
122 let mut res = salsa::QueryConfig::new(); 122 let mut res = salsa::QueryConfig::new();
123 let queries: Vec<SalsaGroundQuery> = vec![ 123 let queries: Vec<BoxedGroundQuery> = vec![
124 queries::FILE_TEXT.into(), 124 queries::FILE_TEXT.into(),
125 queries::FILE_SET.into(), 125 queries::FILE_SET.into(),
126 ]; 126 ];
127 for q in queries { 127 for q in queries {
128 res = res.with_ground_query(q.query_type, q.f) 128 res = res.with_ground_query(q.query_type, q.f)
129 } 129 }
130 let queries: Vec<SalsaQuery> = vec![ 130 let mut queries: Vec<BoxedQuery> = vec![
131 queries::FILE_SYNTAX.into(), 131 queries::FILE_SYNTAX.into(),
132 ::module_map_db::MODULE_DESCR.into(),
133 ::module_map_db::RESOLVE_SUBMODULE.into(),
134 ::module_map_db::PARENT_MODULE.into(),
135 ]; 132 ];
133 ::module_map_db::queries(&mut queries);
136 for q in queries { 134 for q in queries {
137 res = res.with_query(q.query_type, q.f); 135 res = res.with_query(q.query_type, q.f);
138 } 136 }
139 res 137 res
140} 138}
141 139
142struct SalsaGroundQuery { 140struct BoxedGroundQuery {
143 query_type: salsa::QueryTypeId, 141 query_type: salsa::QueryTypeId,
144 f: Box<Fn(&State, &Data) -> (Data, salsa::OutputFingerprint) + Send + Sync + 'static>, 142 f: Box<Fn(&State, &Data) -> (Data, salsa::OutputFingerprint) + Send + Sync + 'static>,
145} 143}
146 144
147impl<T, R> From<GroundQuery<T, R>> for SalsaGroundQuery 145impl<T, R> From<GroundQuery<T, R>> for BoxedGroundQuery
148where 146where
149 T: Send + Sync + 'static, 147 T: Send + Sync + 'static,
150 R: Send + Sync + 'static, 148 R: Send + Sync + 'static,
151{ 149{
152 fn from(q: GroundQuery<T, R>) -> SalsaGroundQuery 150 fn from(q: GroundQuery<T, R>) -> BoxedGroundQuery
153 { 151 {
154 SalsaGroundQuery { 152 BoxedGroundQuery {
155 query_type: salsa::QueryTypeId(q.id), 153 query_type: salsa::QueryTypeId(q.id),
156 f: Box::new(move |state, data| { 154 f: Box::new(move |state, data| {
157 let data: &T = data.downcast_ref().unwrap(); 155 let data: &T = data.downcast_ref().unwrap();
@@ -163,19 +161,19 @@ where
163 } 161 }
164} 162}
165 163
166struct SalsaQuery { 164pub(crate) struct BoxedQuery {
167 query_type: salsa::QueryTypeId, 165 query_type: salsa::QueryTypeId,
168 f: Box<Fn(&salsa::QueryCtx<State, Data>, &Data) -> (Data, salsa::OutputFingerprint) + Send + Sync + 'static>, 166 f: Box<Fn(&salsa::QueryCtx<State, Data>, &Data) -> (Data, salsa::OutputFingerprint) + Send + Sync + 'static>,
169} 167}
170 168
171impl<T, R> From<Query<T, R>> for SalsaQuery 169impl<T, R> From<Query<T, R>> for BoxedQuery
172where 170where
173 T: Hash + Send + Sync + 'static, 171 T: Hash + Send + Sync + 'static,
174 R: Hash + Send + Sync + 'static, 172 R: Hash + Send + Sync + 'static,
175{ 173{
176 fn from(q: Query<T, R>) -> SalsaQuery 174 fn from(q: Query<T, R>) -> BoxedQuery
177 { 175 {
178 SalsaQuery { 176 BoxedQuery {
179 query_type: salsa::QueryTypeId(q.id), 177 query_type: salsa::QueryTypeId(q.id),
180 f: Box::new(move |ctx, data| { 178 f: Box::new(move |ctx, data| {
181 let ctx = QueryCtx { inner: ctx }; 179 let ctx = QueryCtx { inner: ctx };