Don't suggest "there is a method with a similar name" for crates that are not used as a dependency
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
let mut cvt = Convert::new(Isin::default());
Current output
help: there is a method `default_color` with a similar name
|
207 | let mut cvt = Convert::new(Isin::default_color());
| ~~~~~~~~~~~~~
Desired output
It shouldn't mention `default_color`
Rationale and extra context
Let's start with the code I pasted. Isin doesn't implement Default trait so default method is not available.
rustc suggests Isin::default_color() - a trait from OwoColorize that is not in scope so if you substitute that - it fails with a new error message
"error[E0599]: no function or associated item named `default_color` found for struct `isin::Isin` in the current scope
--> xxx/src/lib.rs:207:42
And it also suggests to import the trait.
help: trait `OwoColorize` which provides `default_color` is implemented but not in scope; perhaps you want to import it
|
202 + use owo_colors::OwoColorize;
|
help: there is a method `on_default_color` with a similar name
|
207 | let mut cvt = Convert::new(Isin::on_default_color());
| ~~~~~~~~~~~~~~~~
This suggestion also fails since owo_colors is not a direct dependency of a crate I'm working with, it is used internally by some other dependency.
Other cases
Rust Version
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7
Anything else?
No response
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.
Research direction
Start by reproducing the diagnostic from the Rust code snippet with rustc 1.85.0 and trace the compiler's method-suggestion path. The work is done when methods from crates that are not direct dependencies are no longer suggested, while the remaining diagnostics and valid suggestions still work.
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
- 48/100