| 1 | #[macro_export] |
| 2 | macro_rules! setup_tracked_assoc_fn_body { |
| 3 | ( |
| 4 | salsa_tracked_attr: #[$salsa_tracked_attr:meta], |
| 5 | self_ty: $self_ty:ty, |
| 6 | db_lt: $($db_lt:lifetime)?, |
| 7 | db: $db:ident, |
| 8 | db_ty: ($($db_ty:tt)*), |
| 9 | input_ids: [$($input_id:ident),*], |
| 10 | input_tys: [$($input_ty:ty),*], |
| 11 | output_ty: $output_ty:ty, |
| 12 | inner_fn_name: $inner_fn_name:ident, |
| 13 | inner_fn: $inner_fn:item, |
| 14 | tracked_fn: $tracked_fn:item, |
| 15 | |
| 16 | // Annoyingly macro-rules hygiene does not extend to items defined in the macro. |
| 17 | // We have the procedural macro generate names for those items that are |
| 18 | // not used elsewhere in the user's code. |
| 19 | unused_names: [ |
| 20 | $InnerTrait:ident, |
| 21 | ] |
| 22 | ) => { |
| 23 | { |
| 24 | trait $InnerTrait<$($db_lt)?> { |
| 25 | fn $inner_fn_name(db: $($db_ty)*, $($input_id: $input_ty),*) -> $output_ty; |
| 26 | } |
| 27 | |
| 28 | impl<$($db_lt)?> $InnerTrait<$($db_lt)?> for $self_ty { |
| 29 | $inner_fn |
| 30 | } |
| 31 | |
| 32 | $tracked_fn |
| 33 | |
| 34 | $inner_fn_name($db, $($input_id),*) |
| 35 | } |
| 36 | }; |
| 37 | } |