rust-lang / rust-lang/reference
Metavariable repetition in the matcher and the transcriber
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- PR merge metrics
- PR metrics pending
Description
According to chapter 3.1., a metavariable must appear in exactly the same number, kind, and nesting order of repetitions in the transcriber as it did in the matcher. Based on this, I expected the following code (playground) not to compile, but it does compile without error.
macro_rules! repeat1 {
($($x:expr),+) => {
$(let _ = $x;)*
};
}
macro_rules! repeat2 {
($($x:expr),+) => {
$(let _ = $x;)?
};
}
macro_rules! repeat3 {
($($x:expr),*) => {
$(let _ = $x;)?
};
}
fn main() {
repeat1!(1,2,3);
repeat2!(1,2,3);
repeat3!(1,2,3);
}
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 chapter 3.1 of the Rust Reference and reproduce the repeat1, repeat2, and repeat3 examples from the issue or its playground link. Compare the stated metavariable repetition rule with the observed compiler behavior, then determine whether the Reference wording or the documented examples need correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100