Skip to content

Skip #[test_case] expansion #18275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/hir-def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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()));
Expand Down
3 changes: 3 additions & 0 deletions crates/hir-expand/src/builtin/attr_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down