Closed
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
Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: Name/path resolution done by `rustc_resolve` specificallyDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.