diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-20 06:47:59 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-21 10:16:09 +1100 |
| commit | 8ac16c6193f6b694e5b05ff2209caafac792e760 (patch) | |
| tree | 771b050df67ac4bb177e7354f56d05643c9d4c6e /tests/ui/parser/attribute | |
| parent | d919dbe370e28c53498acb13be80fc30097451fa (diff) | |
| download | rust-8ac16c6193f6b694e5b05ff2209caafac792e760.tar.gz rust-8ac16c6193f6b694e5b05ff2209caafac792e760.zip | |
Rewrite `parse_meta_item`.
It can't use `maybe_whole`, but it can match `maybe_whole` more closely. Also add a test for a case that wasn't previously covered.
Diffstat (limited to 'tests/ui/parser/attribute')
| -rw-r--r-- | tests/ui/parser/attribute/attr-bad-meta-4.rs | 12 | ||||
| -rw-r--r-- | tests/ui/parser/attribute/attr-bad-meta-4.stderr | 25 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.rs b/tests/ui/parser/attribute/attr-bad-meta-4.rs new file mode 100644 index 00000000000..cedbd1d6686 --- /dev/null +++ b/tests/ui/parser/attribute/attr-bad-meta-4.rs @@ -0,0 +1,12 @@ +macro_rules! mac { + ($attr_item: meta) => { + #[cfg($attr_item)] + //~^ ERROR expected unsuffixed literal or identifier, found `an(arbitrary token stream)` + //~| ERROR expected unsuffixed literal or identifier, found `an(arbitrary token stream)` + struct S; + } +} + +mac!(an(arbitrary token stream)); + +fn main() {} diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.stderr b/tests/ui/parser/attribute/attr-bad-meta-4.stderr new file mode 100644 index 00000000000..a543bcb692e --- /dev/null +++ b/tests/ui/parser/attribute/attr-bad-meta-4.stderr @@ -0,0 +1,25 @@ +error: expected unsuffixed literal or identifier, found `an(arbitrary token stream)` + --> $DIR/attr-bad-meta-4.rs:3:15 + | +LL | #[cfg($attr_item)] + | ^^^^^^^^^^ +... +LL | mac!(an(arbitrary token stream)); + | -------------------------------- in this macro invocation + | + = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected unsuffixed literal or identifier, found `an(arbitrary token stream)` + --> $DIR/attr-bad-meta-4.rs:3:15 + | +LL | #[cfg($attr_item)] + | ^^^^^^^^^^ +... +LL | mac!(an(arbitrary token stream)); + | -------------------------------- in this macro invocation + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + |
