Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add test to guard against inaccurate diagnostic
Also replaces an incomplete test
  • Loading branch information
tshepang committed Feb 17, 2024
commit e3859d206ce49998f0f33e0c7fceca261aeaf7e8
10 changes: 10 additions & 0 deletions tests/ui/macros/invalid-fragment-specifier.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have tests for invalid fragment specifiers, e.g., tests/ui/macros/macro-invalid-fragment-spec.rs. Actually instead of modifying this old test file, could you just remove it in favor of the new one you just added. I like your test file way better. After that, we're good to go!

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
macro_rules! test {
($wrong:id) => {};
} //~^ ERROR: invalid fragment specifier `id`

// guard against breaking raw identifier diagnostic
macro_rules! test_raw_identifer {
($wrong:r#if) => {};
} //~^ ERROR: invalid fragment specifier `r#if`

fn main() {}
18 changes: 18 additions & 0 deletions tests/ui/macros/invalid-fragment-specifier.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: invalid fragment specifier `id`
--> $DIR/invalid-fragment-specifier.rs:2:6
|
LL | ($wrong:id) => {};
| ^^^^^^^^^
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`

error: invalid fragment specifier `r#if`
--> $DIR/invalid-fragment-specifier.rs:7:6
|
LL | ($wrong:r#if) => {};
| ^^^^^^^^^^^
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`

error: aborting due to 2 previous errors

8 changes: 0 additions & 8 deletions tests/ui/macros/macro-invalid-fragment-spec.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/macros/macro-invalid-fragment-spec.stderr

This file was deleted.