Skip to content

Commit e20d12a

Browse files
committed
internal: flatten match expressions
1 parent 3c2e106 commit e20d12a

File tree

1 file changed

+7
-30
lines changed
  • crates/query-group-macro/src

1 file changed

+7
-30
lines changed

crates/query-group-macro/src/lib.rs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ pub(crate) fn query_group_impl(
290290
.push(TraitItem::Fn(make_trait_method(method.signature.clone())));
291291
lookup_methods.push(method);
292292
}
293-
// tracked function without *any* invoke.
294-
(QueryKind::Tracked, None) => {
293+
// tracked function. it might have an invoke, or might not.
294+
(QueryKind::Tracked, invoke) => {
295295
let method = TrackedQuery {
296296
trait_name: trait_name_ident.clone(),
297297
generated_struct: Some(GeneratedInputStruct {
@@ -300,30 +300,13 @@ pub(crate) fn query_group_impl(
300300
}),
301301
signature: signature.clone(),
302302
pat_and_tys: pat_and_tys.clone(),
303-
invoke: None,
303+
invoke,
304304
cycle,
305305
lru,
306306
};
307307

308308
trait_methods.push(Queries::TrackedQuery(method));
309309
}
310-
// tracked function with an invoke
311-
(QueryKind::Tracked, Some(invoke)) => {
312-
let method = TrackedQuery {
313-
trait_name: trait_name_ident.clone(),
314-
generated_struct: Some(GeneratedInputStruct {
315-
input_struct_name: input_struct_name.clone(),
316-
create_data_ident: create_data_ident.clone(),
317-
}),
318-
signature: signature.clone(),
319-
pat_and_tys: pat_and_tys.clone(),
320-
invoke: Some(invoke),
321-
cycle,
322-
lru,
323-
};
324-
325-
trait_methods.push(Queries::TrackedQuery(method))
326-
}
327310
(QueryKind::TrackedWithSalsaStruct, Some(invoke)) => {
328311
let method = TrackedQuery {
329312
trait_name: trait_name_ident.clone(),
@@ -337,20 +320,14 @@ pub(crate) fn query_group_impl(
337320

338321
trait_methods.push(Queries::TrackedQuery(method))
339322
}
323+
// while it is possible to make this reachable, it's not really worthwhile for a migration aid.
324+
// doing this would require attaching an attribute to the salsa struct parameter in the query.
340325
(QueryKind::TrackedWithSalsaStruct, None) => unreachable!(),
341-
(QueryKind::Transparent, None) => {
326+
(QueryKind::Transparent, invoke) => {
342327
let method = Transparent {
343328
signature: method.sig.clone(),
344329
pat_and_tys: pat_and_tys.clone(),
345-
invoke: None,
346-
};
347-
trait_methods.push(Queries::Transparent(method));
348-
}
349-
(QueryKind::Transparent, Some(invoke)) => {
350-
let method = Transparent {
351-
signature: method.sig.clone(),
352-
pat_and_tys: pat_and_tys.clone(),
353-
invoke: Some(invoke),
330+
invoke: invoke
354331
};
355332
trait_methods.push(Queries::Transparent(method));
356333
}

0 commit comments

Comments
 (0)