Skip to content

Commit c560660

Browse files
committed
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 #18085).
2 parents 0402da4 + 3d6acb3 commit c560660

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

crates/hir-def/src/nameres/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ impl DefCollector<'_> {
12721272
_ => return Resolved::No,
12731273
};
12741274

1275-
// Skip #[test]/#[bench] expansion, which would merely result in more memory usage
1275+
// Skip #[test]/#[bench]/#[test_case] expansion, which would merely result in more memory usage
12761276
// due to duplicating functions into macro expansions, but only if `cfg(test)` is active,
12771277
// otherwise they are expanded to nothing and this can impact e.g. diagnostics (due to things
12781278
// being cfg'ed out).
@@ -1281,7 +1281,7 @@ impl DefCollector<'_> {
12811281
if matches!(
12821282
def.kind,
12831283
MacroDefKind::BuiltInAttr(_, expander)
1284-
if expander.is_test() || expander.is_bench()
1284+
if expander.is_test() || expander.is_bench() || expander.is_test_case()
12851285
) {
12861286
let test_is_active =
12871287
self.cfg_options.check_atom(&CfgAtom::Flag(sym::test.clone()));

crates/hir-expand/src/builtin/attr_macro.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ impl BuiltinAttrExpander {
5151
pub fn is_bench(self) -> bool {
5252
matches!(self, BuiltinAttrExpander::Bench)
5353
}
54+
pub fn is_test_case(self) -> bool {
55+
matches!(self, BuiltinAttrExpander::TestCase)
56+
}
5457
}
5558

5659
register_builtin! {

0 commit comments

Comments
 (0)