rust-lang / rust-lang/reference
"Macros by example" page mixes language and macro_rules input syntax definitions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- PR merge metrics
- PR metrics pending
Description
My understanding is the reference's syntax sections should represent what is syntactically valid Rust. However, given the current syntax on the Macros by example page it implies the following code is syntactically invalid.
#[cfg(false)]
macro_rules! name {
struct Demo;
}
This in fact compiles fine. The macro_rules! acts as a normal macro call where the body is allowed to be any token stream. This means in the reference the MacroRules should actually be Token*.
I propose the reference be changed so that this page splits the syntax for the language vs the syntax inside macro_rules! calls. This way no content is lost, but the distinction is shown.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Macros by example page and compare its MacroRules syntax section with the distinction described in the issue. Separate the language syntax from the syntax accepted inside macro_rules! while preserving the existing content, and verify that the reference no longer implies the demonstrated valid Rust is syntactically invalid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100