-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messages
Description
Description
Usecase: use pretty_assertions::assert_eq
instead of std::assert_eq
in cfg(test)
But allow using std::assert_eq
in non-test code
You can hack this using #[cfg_attr(test, allow(clippy::disallowed_macros))]
, but this will affect other macros defined in disallowed_macros
when you might only want to do this for a list of macros
Lints affected:
disallowed_macros
disallowed_methods
disallowed_types
Add support to specify cfg
field for disallowed items
disallowed-macros = [
{ cfg = "test", path = "std::assert_ne", reason = "use `pretty_assertions::assert_ne` instead" },
{ cfg = "test", path = "std::assert_eq", reason = "use `pretty_assertions::assert_eq` instead" },
]
Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
Additional Labels
@rustbot label +C-enhancement
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messages