rust-lang / rust-lang/rust-clippy

Add `allow-disallowed-*-in-tests` configuration items

Open
#13,790 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ui C-enhancement L-restriction
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the existing allow-dbg-in-tests and allow-print-in-tests configuration items, then trace the five disallowed_* categories listed in the issue. Implement matching allow-disallowed-*-in-tests options with behavior under #[cfg(test)] gates. Done means each requested category can be disabled in tests without site-specific #[allow] or #[expect] annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.