diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-01 04:25:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-01 04:25:36 +0200 |
| commit | cfe1942a3f1a98ea733b544559bd4845e41d5797 (patch) | |
| tree | d5503c6f0ad2ff03ab758d510e5f2f4981e0ab18 /tests/ui/macros/metavar-expressions/required-feature.rs | |
| parent | e2ea213874477e0874af598eecdb730ef2a52b32 (diff) | |
| parent | a1a066999b9fbfc10e93931d9a552bf87dc32e4d (diff) | |
| download | rust-cfe1942a3f1a98ea733b544559bd4845e41d5797.tar.gz rust-cfe1942a3f1a98ea733b544559bd4845e41d5797.zip | |
Rollup merge of #143245 - tgross35:metavariable-expr-organization, r=petrochenkov
mbe: Add tests and restructure metavariable expressions Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details. This performs the nonfunctional perparation for further changes such as https://github.com/rust-lang/rust/pull/142950 and https://github.com/rust-lang/rust/pull/142975 .
Diffstat (limited to 'tests/ui/macros/metavar-expressions/required-feature.rs')
| -rw-r--r-- | tests/ui/macros/metavar-expressions/required-feature.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/macros/metavar-expressions/required-feature.rs b/tests/ui/macros/metavar-expressions/required-feature.rs new file mode 100644 index 00000000000..77c165e3855 --- /dev/null +++ b/tests/ui/macros/metavar-expressions/required-feature.rs @@ -0,0 +1,43 @@ +macro_rules! count { + ( $( $e:stmt ),* ) => { + ${ count($e) } + //~^ ERROR meta-variable expressions are unstable + }; +} + +macro_rules! dollar_dollar { + () => { + macro_rules! bar { + ( $$( $$any:tt )* ) => { $$( $$any )* }; + //~^ ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + } + }; +} + +macro_rules! index { + ( $( $e:stmt ),* ) => { + $( ${ignore($e)} ${index()} )* + //~^ ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + }; +} + +macro_rules! ignore { + ( $( $i:stmt ),* ) => {{ + 0 $( + 1 ${ignore($i)} )* + //~^ ERROR meta-variable expressions are unstable + }}; +} + +macro_rules! len { + ( $( $e:stmt ),* ) => { + $( ${ignore($e)} ${len()} )* + //~^ ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + }; +} + +fn main() {} |
