about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Richey <davidrichey@fb.com>2024-10-09 19:34:08 -0500
committerDavid Richey <davidrichey@fb.com>2024-10-09 19:34:08 -0500
commitee684c176acdf22b6ee8740b20c7c03e3351244c (patch)
tree390a6547b36b5c034c98b6e498c40ca6c4838da4
parent3e42fc55962fa19557ee2a34de192adebce11c47 (diff)
downloadrust-ee684c176acdf22b6ee8740b20c7c03e3351244c.tar.gz
rust-ee684c176acdf22b6ee8740b20c7c03e3351244c.zip
Skip #[test_case] expansion
-rw-r--r--src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs4
-rw-r--r--src/tools/rust-analyzer/crates/hir-expand/src/builtin/attr_macro.rs3
2 files changed, 5 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs b/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs
index 7f1d19719da..769be872947 100644
--- a/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs
+++ b/src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs
@@ -1323,7 +1323,7 @@ impl DefCollector<'_> {
                         _ => return Resolved::No,
                     };
 
-                    // Skip #[test]/#[bench] expansion, which would merely result in more memory usage
+                    // Skip #[test]/#[bench]/#[test_case] expansion, which would merely result in more memory usage
                     // due to duplicating functions into macro expansions, but only if `cfg(test)` is active,
                     // otherwise they are expanded to nothing and this can impact e.g. diagnostics (due to things
                     // being cfg'ed out).
@@ -1332,7 +1332,7 @@ impl DefCollector<'_> {
                     if matches!(
                         def.kind,
                         MacroDefKind::BuiltInAttr(_, expander)
-                        if expander.is_test() || expander.is_bench()
+                        if expander.is_test() || expander.is_bench() || expander.is_test_case()
                     ) {
                         let test_is_active =
                             self.cfg_options.check_atom(&CfgAtom::Flag(sym::test.clone()));
diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/builtin/attr_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/builtin/attr_macro.rs
index 2a8691b461c..74effd2fb16 100644
--- a/src/tools/rust-analyzer/crates/hir-expand/src/builtin/attr_macro.rs
+++ b/src/tools/rust-analyzer/crates/hir-expand/src/builtin/attr_macro.rs
@@ -51,6 +51,9 @@ impl BuiltinAttrExpander {
     pub fn is_bench(self) -> bool {
         matches!(self, BuiltinAttrExpander::Bench)
     }
+    pub fn is_test_case(self) -> bool {
+        matches!(self, BuiltinAttrExpander::TestCase)
+    }
 }
 
 register_builtin! {