aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-struct-field-expr.h
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-07-20 13:49:53 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-07-20 15:08:51 +0200
commit09855d5c0eb14a9b976a98ae4ec9ab012eebaa51 (patch)
treed3cb79c22ffa2c662d29394c84111771f032a26a /gcc/rust/backend/rust-compile-struct-field-expr.h
parent3f5fc214f4a53ac6c90e421814fcf049e56d3dc9 (diff)
downloadgcc-09855d5c0eb14a9b976a98ae4ec9ab012eebaa51.zip
gcc-09855d5c0eb14a9b976a98ae4ec9ab012eebaa51.tar.gz
gcc-09855d5c0eb14a9b976a98ae4ec9ab012eebaa51.tar.bz2
macro: Allow the repetition of metavars when expanding repetitions
When expanding repeating metavars, we have to allow the repetition of non-repeating metavars as well: ``` macro_rules! foo { ( ( $( $Trait: ident ),+ ) for $Ty: ident ) => { $( impl $Trait for $Ty { fn bar() -> i32 { 14 } } )+ } } trait Foo { fn bar() -> i32; } trait Bar { fn bar() -> i32; } trait Baz { fn bar() -> i32; } trait Qux { fn bar() -> i32; } struct S; foo!{(Foo, Bar, Baz, Qux) for S} ``` This is valid, as the $Ty metavar is not a repetition. However, this should fail to compile: ``` macro_rules! foo { // note the repetition here now ( ( $( $Trait: ident ),+ ) for $($Ty: ident)+ ) => { $( impl $Trait for $Ty { fn bar() -> i32 { 14 } } )+ } } trait Foo { fn bar() -> i32; } trait Bar { fn bar() -> i32; } trait Baz { fn bar() -> i32; } trait Qux { fn bar() -> i32; } struct S; foo!{(Foo, Bar, Baz, Qux) for S} ``` Obviously, if we were to specify as many $Ty as $Trait then there would be no issue, but that behavior is already handled.
Diffstat (limited to 'gcc/rust/backend/rust-compile-struct-field-expr.h')
0 files changed, 0 insertions, 0 deletions