Skip to content

Commit ee684c1

Browse files
committed
Skip #[test_case] expansion
1 parent 3e42fc5 commit ee684c1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ impl DefCollector<'_> {
13231323
_ => return Resolved::No,
13241324
};
13251325

1326-
// Skip #[test]/#[bench] expansion, which would merely result in more memory usage
1326+
// Skip #[test]/#[bench]/#[test_case] expansion, which would merely result in more memory usage
13271327
// due to duplicating functions into macro expansions, but only if `cfg(test)` is active,
13281328
// otherwise they are expanded to nothing and this can impact e.g. diagnostics (due to things
13291329
// being cfg'ed out).
@@ -1332,7 +1332,7 @@ impl DefCollector<'_> {
13321332
if matches!(
13331333
def.kind,
13341334
MacroDefKind::BuiltInAttr(_, expander)
1335-
if expander.is_test() || expander.is_bench()
1335+
if expander.is_test() || expander.is_bench() || expander.is_test_case()
13361336
) {
13371337
let test_is_active =
13381338
self.cfg_options.check_atom(&CfgAtom::Flag(sym::test.clone()));

src/tools/rust-analyzer/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)