Skip to content

Commit

Permalink
Auto merge of rust-lang#18275 - darichey:fix-test-case-hang, r=Veykril
Browse files Browse the repository at this point in the history
Skip #[test_case] expansion

Fixes rust-lang#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 rust-lang/rust-analyzer#18085).
  • Loading branch information
bors committed Oct 14, 2024
2 parents a4df972 + ee684c1 commit b2048df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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()));
Expand Down
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

0 comments on commit b2048df

Please sign in to comment.