Fix unwrap_expect_used in test modules defined by complex configuration predicates (#16369)#16989
Fix unwrap_expect_used in test modules defined by complex configuration predicates (#16369)#16989corentinguilloteau wants to merge 4 commits into
unwrap_expect_used in test modules defined by complex configuration predicates (#16369)#16989Conversation
|
r? @llogiq rustbot has assigned @llogiq. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
2aa7e81 to
8c2d893
Compare
There was a problem hiding this comment.
Hi Corentin, thanks for your contribution.
It would be great if you could handle the CfgEntry::Not case as well, or at least clearly state in the function documentation why it is not handled. There is a risk that some other code in Clippy wants to use cfg_implies_test() for the reverse purpose (ensure that we cannot be in a test settings), and this function would return None for #[cfg(not(test))] while the caller could expect it to return Some(false).
r? samueltardieu
@rustbot author
|
Reminder, once the PR becomes ready for a review, use |
|
I've reworked the initial implementation with a new approach that handles more configuration predicates than the old one (most notably, it now handles the I've also improved the API so that using @rustbot ready |
This PR fixes detection of
testcontexts in complex scenarios (e.g., #[cfg(all(test, ...))]). This allows theunwrap_usedandexpect_usedlints to correctly suppress warnings in test contexts with compound cfg conditions.Note that this also updates the behavior of lints that indirectly depend on
is_cfg_test(around 20 lints).Fixes #16369
changelog: [
unwrap_expect_used]: Fix in test modules defined by complex configuration predicates