Skip to content

Commit ff75ff5

Browse files
committed
internal: flatten match expressions
1 parent 872dc7b commit ff75ff5

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

+7-30
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ pub(crate) fn query_group_impl(
292292
.push(TraitItem::Fn(make_trait_method(method.signature.clone())));
293293
lookup_methods.push(method);
294294
}
295-
// tracked function without *any* invoke.
296-
(QueryKind::Tracked, None) => {
295+
// tracked function. it might have an invoke, or might not.
296+
(QueryKind::Tracked, invoke) => {
297297
let method = TrackedQuery {
298298
trait_name: trait_name_ident.clone(),
299299
generated_struct: Some(GeneratedInputStruct {
@@ -302,30 +302,13 @@ pub(crate) fn query_group_impl(
302302
}),
303303
signature: signature.clone(),
304304
pat_and_tys: pat_and_tys.clone(),
305-
invoke: None,
305+
invoke,
306306
cycle,
307307
lru,
308308
};
309309

310310
trait_methods.push(Queries::TrackedQuery(method));
311311
}
312-
// tracked function with an invoke
313-
(QueryKind::Tracked, Some(invoke)) => {
314-
let method = TrackedQuery {
315-
trait_name: trait_name_ident.clone(),
316-
generated_struct: Some(GeneratedInputStruct {
317-
input_struct_name: input_struct_name.clone(),
318-
create_data_ident: create_data_ident.clone(),
319-
}),
320-
signature: signature.clone(),
321-
pat_and_tys: pat_and_tys.clone(),
322-
invoke: Some(invoke),
323-
cycle,
324-
lru,
325-
};
326-
327-
trait_methods.push(Queries::TrackedQuery(method))
328-
}
329312
(QueryKind::TrackedWithSalsaStruct, Some(invoke)) => {
330313
let method = TrackedQuery {
331314
trait_name: trait_name_ident.clone(),
@@ -339,20 +322,14 @@ pub(crate) fn query_group_impl(
339322

340323
trait_methods.push(Queries::TrackedQuery(method))
341324
}
325+
// while it is possible to make this reachable, it's not really worthwhile for a migration aid.
326+
// doing this would require attaching an attribute to the salsa struct parameter in the query.
342327
(QueryKind::TrackedWithSalsaStruct, None) => unreachable!(),
343-
(QueryKind::Transparent, None) => {
328+
(QueryKind::Transparent, invoke) => {
344329
let method = Transparent {
345330
signature: method.sig.clone(),
346331
pat_and_tys: pat_and_tys.clone(),
347-
invoke: None,
348-
};
349-
trait_methods.push(Queries::Transparent(method));
350-
}
351-
(QueryKind::Transparent, Some(invoke)) => {
352-
let method = Transparent {
353-
signature: method.sig.clone(),
354-
pat_and_tys: pat_and_tys.clone(),
355-
invoke: Some(invoke),
332+
invoke: invoke
356333
};
357334
trait_methods.push(Queries::Transparent(method));
358335
}

0 commit comments

Comments
 (0)