Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #18275 - darichey:fix-test-case-hang, r=Veykril
Skip #[test_case] expansion Fixes #18274, although I don't fully understand if this is the best fix (it's not clear to me why this didn't cause issues before https://github.com/rust-lang/rust-analyzer/pull/18085).
bors 2024-10-14
parent 0402da4 · parent 3d6acb3 · commit c560660
-rw-r--r--crates/hir-def/src/nameres/collector.rs4
-rw-r--r--crates/hir-expand/src/builtin/attr_macro.rs3
2 files changed, 5 insertions, 2 deletions
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index 012dc4773f..22b9c2b4e3 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -1272,7 +1272,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).
@@ -1281,7 +1281,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/crates/hir-expand/src/builtin/attr_macro.rs b/crates/hir-expand/src/builtin/attr_macro.rs
index 2a8691b461..74effd2fb1 100644
--- a/crates/hir-expand/src/builtin/attr_macro.rs
+++ b/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! {