From 842abe5c27204242b0fe714e9115271b56509abe Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 2 Nov 2024 18:01:31 +0100 Subject: [PATCH 1/2] Emit struct in `#[tracked]` fn last for better IDE support --- components/salsa-macro-rules/src/setup_tracked_fn.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/salsa-macro-rules/src/setup_tracked_fn.rs b/components/salsa-macro-rules/src/setup_tracked_fn.rs index 3c85af79..b6182241 100644 --- a/components/salsa-macro-rules/src/setup_tracked_fn.rs +++ b/components/salsa-macro-rules/src/setup_tracked_fn.rs @@ -67,11 +67,6 @@ macro_rules! setup_tracked_fn { $inner:ident, ] ) => { - #[allow(non_camel_case_types)] - $vis struct $fn_name { - _priv: std::convert::Infallible, - } - // Suppress this clippy lint because we sometimes require `'db` where the ordinary Rust rules would not. #[allow(clippy::needless_lifetimes)] $(#[$attr])* @@ -288,5 +283,10 @@ macro_rules! setup_tracked_fn { } }) } + + #[allow(non_camel_case_types)] + $vis struct $fn_name { + _priv: std::convert::Infallible, + } }; } From b0fafce5a5c7a01ebb6946e918ea268f2c754712 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Thu, 7 Nov 2024 10:36:02 -0500 Subject: [PATCH 2/2] Update components/salsa-macro-rules/src/setup_tracked_fn.rs --- components/salsa-macro-rules/src/setup_tracked_fn.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/salsa-macro-rules/src/setup_tracked_fn.rs b/components/salsa-macro-rules/src/setup_tracked_fn.rs index b6182241..79ec96d5 100644 --- a/components/salsa-macro-rules/src/setup_tracked_fn.rs +++ b/components/salsa-macro-rules/src/setup_tracked_fn.rs @@ -283,7 +283,9 @@ macro_rules! setup_tracked_fn { } }) } - + // The struct needs be last in the macro expansion in order to make the tracked + // function's ident be identified as a function, not a struct, during semantic highlighting. + // for more details, see https://github.com/salsa-rs/salsa/pull/612. #[allow(non_camel_case_types)] $vis struct $fn_name { _priv: std::convert::Infallible,