items_after_test_module interacts badly with rstest and submodules #11050
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
I like to organize my tests into multiple modules just to provide namespacing. For example, I might use one module for each function under test, and each of those modules will contain one function for each test case, like this:
The problem is that if anything above the final module includes a
#[cfg(test)]
, then the items_after_test_module lint will fire. That's even true in integration tests, which aren't built with and without#[cfg(test)]
. The problem is exacerbated by macro crates likerstest
, which sometimes emit a#[cfg(test)]
in the generated code. And it's frustrating to debug, because the user can't even see the offending#[cfg(test)]
.I don't know what a perfect solution would be. But skipping this lint in integration tests would be a good start. Or, skipping this lint within an outer module which is itself
#[cfg(test)]
.Lint Name
items_after_test_module
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
No errors (except for
SomethingUsedByTheTest is never constructed
, of course).Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: