Skip to content

rustc shouldn't say 'not in scope' when using a derive macro as a macro_rules macro #76429

Closed
@jyn514

Description

@jyn514

Consider the following code (playground):

fn f() {
    Debug!()
}

#[derive(Debug)]
struct S;
error: cannot find macro `Debug` in this scope
 --> src/lib.rs:2:5
  |
2 |     Debug!()
  |     ^^^^^

This is not particularly helpful (in fact it's incorrect). Debug is in scope, it's just not a macro rules macro. Instead the error should say something like

error: `Debug` is a derive macro, not a macro_rules! macro
 --> src/lib.rs:2:5
  |
2 |     Debug!()
  |     ^^^^^ note: attempting to use a derive as a macro_rules! macro

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions