rust-lang / rust-lang/rust

cannot forbid `dead_code` since lint triggers for third party macros

Open
#126,028 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lints C-bug L-dead_code T-clippy
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

if i, for example, forbid dead_code, clippy produces

error[E0453]: allow(dead_code) incompatible with previous forbid
  |
  | #[derive(Parser, Debug, Clone)]
  |          ^^^^^^ overruled by previous forbid
  |
  = note: `forbid` lint level was set on command line
  = note: this error originates in the derive macro `Parser` (in Nightly builds, run with -Z macro-backtrace for more info)

this is coming from clap's Parser derive macro, which i have no control over, so prevents me from forbidding dead_code in my own crate.

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 reproducing the reported lint interaction with a Rust crate using clap's Parser derive macro and a command-line forbid(dead_code). Trace how the compiler handles lint levels emitted by third-party derive macros; done means the reported macro-generated allow(dead_code) no longer makes the user's forbid unusable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
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.