rust-lang / rust-lang/rust

Errors about unknown attributes when attr macro failed to resolve

Open
#121,555 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-attributes A-diagnostics A-resolve D-verbose T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bf6b5515ea450d277b8556a6f0205911

#[derive(ILove)]
struct A {
    #[beans]
    pub yes: bool,
}
Current output
error: cannot find derive macro `ILove` in this scope
 --> src/lib.rs:1:10
  |
1 | #[derive(ILove)]
  |          ^^^^^

error: cannot find attribute `beans` in this scope
 --> src/lib.rs:3:7
  |
3 |     #[beans]
  |       ^^^^^
Desired output
error: cannot find derive macro `ILove` in this scope
 --> src/lib.rs:1:10
  |
1 | #[derive(ILove)]
  |          ^^^^^
Rationale and extra context

The beans attribute may be provided by the proc macro, this error is a useless and noisy follow-up error which should be suppressed.

Other cases
#[you_love]
struct A {
    #[beans]
    pub yes: bool,
}
Rust Version
nightly-2024-02-24
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 diagnostic using the Rust Playground example and nightly-2024-02-24, including both the failing derive macro and the unknown attribute cases. Trace the compiler's handling of attributes after an unresolved derive or attribute macro; done means the follow-up cannot find attribute error is suppressed while the unresolved derive error remains.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.