See no difference when use quantificator symbol in macros expression

Could somebody explain why this two macroses works the same?

#[macro_export]
macro_rules! vec2 {
    ( $( $x:expr ),* ) => {
        {
            let mut temp_vec = Vec::new();
            $(
                temp_vec.push($x);
            )? // this one works the same as below
            temp_vec
        }
    };
}

#[macro_export]
macro_rules! vec3 {
    ( $( $x:expr ),* ) => {
        {
            let mut temp_vec = Vec::new();
            $(
                temp_vec.push($x);
            )* // this one works the same as above
            temp_vec
        }
    };
}

This is sandbox.

Hmmm I'm surprised that isn't an error. I don't really think it makes sense to use a different repetition operator in the expansion, so I imagine it just isn't being checked at all (other than that it exists, not using a repetition operator is still an error)

1 Like

I created a bug report for this case.

1 Like