rust-lang / rust-lang/rust-clippy

disallowed_methods falsely claiming "does not refer to a reachable function" (workspaces?)

Open
#17,006 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

In our codebase, we see the warning "does not refer to a reachable function" for one of the methods we have disabled in our clippy.toml using disallowed_methods.

I suspect that this is because the method is in a crate that is not a dependency of every crate in our worksapce? Or something.

Lint Name

disallowed_methods

Reproducer

Steps

git clone https://gitlab.torproject.org/tpo/core/arti
cd arti
git checkout f7b6a9d27408d07fafce9c90530177abe7b751ab
cargo clippy --locked --all-features --workspace --all-targets

Expected results

No warnings.

Actual results

warning: `rand::RngExt::random_range` does not refer to a reachable function
 --> /volatile/rustcargo/d/arti/clippy.toml:7:5
  |
7 |     { path = "rand::RngExt::random_range", reason = "Prefer tor_basic_utils::RngExt::gen_range_checked to avoid uncontrolled panics, or gen_range_infallible if applicable" },
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `allow-invalid = true` to the entry to suppress this warning
 
warning: `tor-geoip` (lib test) generated 1 warning
Version
rustc 1.96.0-beta.5 (a5a9a5438 2026-05-01)
binary: rustc
commit-hash: a5a9a5438ba8f6b83523031de99b15c12b44cea4
commit-date: 2026-05-01
host: x86_64-unknown-linux-gnu
release: 1.96.0-beta.5
LLVM version: 22.1.2
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

Reproduce the warning by checking out the stated arti commit and running the provided cargo clippy command. Start with the disallowed_methods lint and the rand::RngExt::random_range entry in clippy.toml; the work is done when valid workspace configuration no longer produces the false reachability warning, while genuinely invalid entries remain diagnosable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.