From 266643440c94d883190feff2f36650476e78e6a4 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 15 May 2024 11:42:05 +0200 Subject: [PATCH] rust: reduce false positives in runnables query (#11845) We were marking `#[cfg(test)]`ed function as a test, which is wrong. Also allow for other attribute_items (such as #[should_panic]) between test attribute and a function item. Release Notes: - N/A --- crates/languages/src/rust/runnables.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/languages/src/rust/runnables.scm b/crates/languages/src/rust/runnables.scm index 400d1aa844..a0409623b8 100644 --- a/crates/languages/src/rust/runnables.scm +++ b/crates/languages/src/rust/runnables.scm @@ -1,6 +1,11 @@ ( - (attribute_item (attribute) @attribute - (#match? @attribute ".*test")) + (attribute_item (attribute + [((identifier) @_attribute) + (scoped_identifier (identifier) @_attribute) + ]) + (#eq? @_attribute "test")) + . + (attribute_item) * . (function_item name: (_) @run)