diff options
| author | Vincenzo Palazzo <vincenzopalazzodev@gmail.com> | 2024-04-16 20:47:10 +0200 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2024-05-13 11:55:26 -0700 |
| commit | a55d06323aef19040aba222b7ede790291e08468 (patch) | |
| tree | d2b934c1cc39ca6ee5027e81c873b8bb31d872d4 /tests | |
| parent | 73303c3b454379772053957d88437277a121c173 (diff) | |
| download | rust-a55d06323aef19040aba222b7ede790291e08468.tar.gz rust-a55d06323aef19040aba222b7ede790291e08468.zip | |
Macros: match const { ... } with expr nonterminal in edition 2024
Co-authored-by: Eric Holk <eric@theincredibleholk.org> Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/macros/expr_2021_inline_const.edi2021.stderr | 32 | ||||
| -rw-r--r-- | tests/ui/macros/expr_2021_inline_const.edi2024.stderr | 17 | ||||
| -rw-r--r-- | tests/ui/macros/expr_2021_inline_const.rs | 23 |
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr new file mode 100644 index 00000000000..5e880964454 --- /dev/null +++ b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr @@ -0,0 +1,32 @@ +error: no rules expected the token `const` + --> $DIR/expr_2021_inline_const.rs:21:12 + | +LL | macro_rules! m2021 { + | ------------------ when calling this macro +... +LL | m2021!(const { 1 }); + | ^^^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr_2021` + --> $DIR/expr_2021_inline_const.rs:10:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: no rules expected the token `const` + --> $DIR/expr_2021_inline_const.rs:22:12 + | +LL | macro_rules! m2024 { + | ------------------ when calling this macro +... +LL | m2024!(const { 1 }); + | ^^^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/expr_2021_inline_const.rs:16:6 + | +LL | ($e:expr) => { + | ^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr new file mode 100644 index 00000000000..237ecb2cc19 --- /dev/null +++ b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr @@ -0,0 +1,17 @@ +error: no rules expected the token `const` + --> $DIR/expr_2021_inline_const.rs:21:12 + | +LL | macro_rules! m2021 { + | ------------------ when calling this macro +... +LL | m2021!(const { 1 }); + | ^^^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr_2021` + --> $DIR/expr_2021_inline_const.rs:10:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/expr_2021_inline_const.rs b/tests/ui/macros/expr_2021_inline_const.rs new file mode 100644 index 00000000000..ebc5ea36421 --- /dev/null +++ b/tests/ui/macros/expr_2021_inline_const.rs @@ -0,0 +1,23 @@ +//@ revisions: edi2021 edi2024 +//@[edi2024]compile-flags: --edition=2024 -Z unstable-options +//@[edi2021]compile-flags: --edition=2021 + +// This test ensures that the inline const match only on edition 2024 +#![feature(expr_fragment_specifier_2024)] +#![allow(incomplete_features)] + +macro_rules! m2021 { + ($e:expr_2021) => { + $e + }; +} + +macro_rules! m2024 { + ($e:expr) => { + $e + }; +} +fn main() { + m2021!(const { 1 }); //~ ERROR: no rules expected the token `const` + m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected the token `const` +} |
