add test to guard against inaccurate diagnostic

Also replaces an incomplete test
This commit is contained in:
Tshepang Mbambo 2024-02-17 14:15:22 +02:00
parent 3a917cdfcb
commit e3859d206c
4 changed files with 28 additions and 18 deletions

View file

@ -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() {}

View file

@ -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

View file

@ -1,8 +0,0 @@
macro_rules! foo(
($x:foo) => ()
//~^ ERROR invalid fragment specifier
);
fn main() {
foo!(foo);
}

View file

@ -1,10 +0,0 @@
error: invalid fragment specifier `foo`
--> $DIR/macro-invalid-fragment-spec.rs:2:6
|
LL | ($x:foo) => ()
| ^^^^^^
|
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
error: aborting due to 1 previous error