Repository navigation
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call 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.Call 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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! macroReacted by trevyn, Mikail Bagishov, Kyle, Aaron Hill, Sean Pianka, Luke, runiq and johannes
Reacted by scottmcm
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call 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.Call 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
jyn514 commentedon Sep 7, 2020
This would have caught the second 'library error' in https://jyn514.github.io/2020/09/05/Rust-in-2021.html.
petrochenkov commentedon Sep 7, 2020
The desirable error was reported previously, but it changed with introduction of two sub-namespaces in macro namespace - #54069.
So, derive
Debugis never found during regular name lookup now for names in fn-like macro positions (Debug!).So it needs a second lookup for diagnostics, which is currently done for other namespaces, but not other sub-namespaces in the macro namespace.
Compare with:
dario23 commentedon May 17, 2023
Current playground correctly says
so let's close this? @jyn514
jyn514 commentedon May 17, 2023
oh amazing, good find!