rust-lang / rust-lang/rust-clippy

Not possible to silence new lint about dbg in tests without editing tree

Open
#8,973 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

In our project we want to allow use of dbg! in tests. I filed issues about this #8481 and #8758 and kind contributors implemented my request. However, this turned out to be controversial - #8838. To deal with this a new configuration file item was introduced, allow-dbg-in-tests, #8897.

However, it is not possible to use this to re-allow dbg! in tests (which are allowed by stable clippy) in a project which wants to compile both with stable and nightly.

This is because stable clippy does not understand the new config option and rejects it; whereas unstable clippy hates dbg! in tests by default.

IMO the default fof allow-dbg-in-tests ought to be true. The rationale for forbidding dbg! does not apply to test code. That some people have a different opinion doesn't invalidate that.

However, there are also some underlying issues:

  • clippy should tolerate (or at least, be capable of tolerating) unknown configuration options, so that the same file can generally be used with multiple versions
  • It should be possible to specify an alternative config file location on the command line.
  • It should be possible to specify configuration variables on the command line piecemeal.
Reproducer

No response

Version

No response

Additional Labels

No response

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

The issue centers on the allow-dbg-in-tests configuration and Clippy's handling of unknown options across stable and nightly versions. It also lists alternative configuration-file paths and piecemeal command-line configuration as related goals, but provides no files, tests, entry points, or concrete definition of done.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.