-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
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-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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
Code
macro_rules! {
() => {};
}
Current output
error: cannot find macro `macro_rules` in this scope
--> src/main.rs:1:1
|
1 | macro_rules! {
| ^^^^^^^^^^^
Desired output
error: `macro_rules` needs to be given a name for the macro you are defining
--> src/main.rs:1:14
|
1 | macro_rules! {
| ^ put a macro name here
Rationale and extra context
The syntax for how an ident is given to macro_rules!
is unlike any other macro invocation. New Rust users would typically have more experience calling macros (println!
) before defining their own macros. There may be a period in which the bespoke macro_rules
syntax is tricky to build muscle memory for.
Other cases
When name of a function is omitted, this is still a better error than "cannot find 'fn' in this scope".
fn() {
}
error: expected identifier, found `(`
--> src/lib.rs:1:3
|
1 | fn() {
| ^ expected identifier
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-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.