`disallowed-methods` and similar options don't respect renamed renamed dependencies in Cargo.toml

Open
#17,585 1 comment 0 reactions 1 assignee View on GitHub

@fyrsta7 is already working on this.

Since Aug 24, 2026.

Assessment

This issue has not been assessed yet.

Description

C-bug I-false-negative
Summary

If a dependency is renamed in Cargo.toml, the disallowed-methods option in clippy.toml uses the original name of the dependency rather than the new name. Similar options like disallowed-types have the same behavior too.

Lint Name

disallowed_methods

Reproducer

Steps to reproduce:

  1. Run cargo new renamed-dependency-test && cd renamed-dependency-test.

  2. Edit Cargo.toml to read:

    [package]
    name = "renamed-dependency-test"
    version = "0.1.0"
    edition = "2024"
    
    [dependencies]
    renamed_rand = { package = "rand", version = "0.10" }
    
  3. Edit src/main.rs to read:

    #![deny(clippy::disallowed_methods)]
    
    fn main() {
        let _: u32 = renamed_rand::random();
    }
    
  4. Create clippy.toml with the following contents:

    [[disallowed-methods]]
    path = "renamed_rand::random"
    
  5. Run cargo clippy.

Expectation: I expected Clippy to reject this code because it uses the disallowed method renamed_rand::random.

Reality: Clippy accepts this code without errors or warnings. If I change clippy.toml to read:

[[disallowed-methods]]
path = "rand::random"

then I get the expected error, but this is confusing because in my code, the function is called renamed_rand::random, not rand::random. If I wrote rand::random() in main.rs my crate wouldn't compile.

Version
rustc 1.100.0-nightly (34baba539 2026-08-16)
binary: rustc
commit-hash: 34baba5394fcbda4cba7b7c1964a6db421c77c91
commit-date: 2026-08-16
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

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.

More from rust-lang/rust-clippy

All issues in rust-lang/rust-clippy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.