Skip to content

Metavariable repetition in the matcher and the transcriber #1671

Open
@pazmank

Description

@pazmank

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); 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions