`disallowed-methods` and similar options don't respect renamed renamed dependencies in Cargo.toml
@fyrsta7 is already working on this.
Since Aug 24, 2026.
Assessment
This issue has not been assessed yet.
Description
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:
-
Run
cargo new renamed-dependency-test && cd renamed-dependency-test. -
Edit
Cargo.tomlto read:[package] name = "renamed-dependency-test" version = "0.1.0" edition = "2024" [dependencies] renamed_rand = { package = "rand", version = "0.10" } -
Edit
src/main.rsto read:#![deny(clippy::disallowed_methods)] fn main() { let _: u32 = renamed_rand::random(); } -
Create
clippy.tomlwith the following contents:[[disallowed-methods]] path = "renamed_rand::random" -
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust-clippy
-
C-bug L-suggestion
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/rust-clippy#17674 · 5 comments ·
-
C-bug L-suggestion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-clippy#17673 · 3 comments ·
-
C-bug I-false-positive
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-lang/rust-clippy#17566 ·
-
A-documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust-clippy#17259 · 3 comments ·
-
A-documentation A-website C-bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-clippy#16981 · 1 reaction ·
All issues in rust-lang/rust-clippy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100