diff options
| author | Tshepang Mbambo <tshepang@gmail.com> | 2024-02-17 14:15:22 +0200 |
|---|---|---|
| committer | Tshepang Mbambo <tshepang@gmail.com> | 2024-02-17 14:15:22 +0200 |
| commit | e3859d206ce49998f0f33e0c7fceca261aeaf7e8 (patch) | |
| tree | 08fa10cfa15c68177f9a1524fee407f1b5f12667 | |
| parent | 3a917cdfcb59b952f130443ececdb6cf98a2ba3b (diff) | |
| download | rust-e3859d206ce49998f0f33e0c7fceca261aeaf7e8.tar.gz rust-e3859d206ce49998f0f33e0c7fceca261aeaf7e8.zip | |
add test to guard against inaccurate diagnostic
Also replaces an incomplete test
| -rw-r--r-- | tests/ui/macros/invalid-fragment-specifier.rs | 10 | ||||
| -rw-r--r-- | tests/ui/macros/invalid-fragment-specifier.stderr | 18 | ||||
| -rw-r--r-- | tests/ui/macros/macro-invalid-fragment-spec.rs | 8 | ||||
| -rw-r--r-- | tests/ui/macros/macro-invalid-fragment-spec.stderr | 10 |
4 files changed, 28 insertions, 18 deletions
diff --git a/tests/ui/macros/invalid-fragment-specifier.rs b/tests/ui/macros/invalid-fragment-specifier.rs new file mode 100644 index 00000000000..1daf0a95434 --- /dev/null +++ b/tests/ui/macros/invalid-fragment-specifier.rs @@ -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() {} diff --git a/tests/ui/macros/invalid-fragment-specifier.stderr b/tests/ui/macros/invalid-fragment-specifier.stderr new file mode 100644 index 00000000000..7516dbc3a08 --- /dev/null +++ b/tests/ui/macros/invalid-fragment-specifier.stderr @@ -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 + diff --git a/tests/ui/macros/macro-invalid-fragment-spec.rs b/tests/ui/macros/macro-invalid-fragment-spec.rs deleted file mode 100644 index dc4d75096af..00000000000 --- a/tests/ui/macros/macro-invalid-fragment-spec.rs +++ /dev/null @@ -1,8 +0,0 @@ -macro_rules! foo( - ($x:foo) => () - //~^ ERROR invalid fragment specifier -); - -fn main() { - foo!(foo); -} diff --git a/tests/ui/macros/macro-invalid-fragment-spec.stderr b/tests/ui/macros/macro-invalid-fragment-spec.stderr deleted file mode 100644 index 919111ede51..00000000000 --- a/tests/ui/macros/macro-invalid-fragment-spec.stderr +++ /dev/null @@ -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 - |
