Skip to content

Commit

Permalink
add test to guard against inaccurate diagnostic
Browse files Browse the repository at this point in the history
Also replaces an incomplete test
  • Loading branch information
tshepang committed Feb 17, 2024
1 parent 3a917cd commit e3859d2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
10 changes: 10 additions & 0 deletions tests/ui/macros/invalid-fragment-specifier.rs
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.

0 comments on commit e3859d2

Please sign in to comment.