rust-lang / rust-lang/rust-clippy

`cargo clippy --all-targets` issues diagnostics for library crate twice

Open
#4,092 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Given a crate containing this file as src/lib.rs

pub fn demo() -> &'static str {
    return "demo";
}

and at least one file in tests that does use name_of_crate::demo, cargo clippy --all-targets will diagnose the needless_return twice in a row. If you use cargo --verbose it's clear that the clippy-driver program has been invoked twice (once with --test and once without) and each invocation is reporting the lint, but without that, it looks like clippy is repeating itself for no reason.

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

Reproduce with the shown src/lib.rs and a file under tests that imports demo, then run cargo clippy --all-targets and compare it with cargo --verbose. Trace the two clippy-driver invocations, one with --test and one without; done means the needless_return diagnostic is reported only once.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.