Skip to content

Add allow-disallowed-*-in-tests configuration items #13790

Open
@PaulDance

Description

@PaulDance

Description

Dear maintainers,

Whenever using one of the disallowed-* lints, one may only specify what is to be enabled, but very little is provided to conditionally disable. This makes workspace-wide refactors often tedious as one needs to #[allow] or #[expect] each use site of a macro, method, ... in tests (and other non-production modules) when adding a new element to one of these disallowed lists.

In parallel of things like #8477 and #11433, an element that should therefore be both relatively easy and quickly useful to implement would be new configuration items for each of, in order of estimated priority:

  • disallowed_methods
  • disallowed_macros
  • disallowed_types
  • disallowed_names
  • disallowed_script_idents

to allow one to disable the lint under #[cfg(test)] gates, in a fashion as similar as possible to allow-dbg-in-tests or allow-print-in-tests for instance. The name for each could be allow-disallowed-*-in-tests, for example allow-disallowed-macros-in-tests.

Thanks in advance,
Paul.

Version

rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1

Additional Labels

@rustbot label +C-enhancement +A-ui +L-restriction

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-uiArea: Clippy interface, usage and configurationC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-restrictionLint: Belongs in the restriction lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions