rust-lang / rust-lang/rust

Similarly named macros aren't suggested for incorrect macro names in anyhow

Open
#117,719 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-macros T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

Code
use anyhow;

fn main() {
    // should be format_err!()
    anyhow::format_error!("foo");
}
Current output
error[E0433]: failed to resolve: could not find `format_error` in `anyhow`
 --> src/main.rs:5:13
  |
5 |     anyhow::format_error!("foo");
  |             ^^^^^^^^^^^^ could not find `format_error` in `anyhow`
Desired output
error[E0433]: failed to resolve: could not find `format_error` in `anyhow`
 --> src/main.rs:5:13
  |
5 |     anyhow::format_error!("foo");
  |             ^^^^^^^^^^^^ help: a macro with a similar name exists: `format_err`
Rationale and extra context

This works for ppanic!(), so maybe the threshold similarity threshold isn't being met in the anyhow case?

Other cases

No response

Anything else?

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 Rust compiler diagnostic with the anyhow::format_error! example and compare it with the ppanic! case mentioned in the issue. Start by tracing the compiler's unresolved macro-name suggestion logic and its similarity threshold; done means the error suggests format_err! for the shown code without regressing existing suggestions.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.