Skip to content

Commit 89a65a2

Browse files
committed
underscore-ident-matcher
1 parent def50d5 commit 89a65a2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tests/ui/macros/macro-fragment-ident-underscore-error.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
//! Verifies that the reserved underscore `_` cannot be used as an `ident` fragment specifier
2+
//! within a macro pattern, as it leads to a compilation error.
3+
14
macro_rules! identity {
2-
($i: ident) => (
5+
($i: ident) => {
36
$i
4-
)
7+
};
58
}
69

710
fn main() {

tests/ui/macros/macro-fragment-ident-underscore-error.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: no rules expected reserved identifier `_`
2-
--> $DIR/underscore-ident-matcher.rs:8:19
2+
--> $DIR/macro-fragment-ident-underscore-error.rs:11:19
33
|
44
LL | macro_rules! identity {
55
| --------------------- when calling this macro
@@ -8,9 +8,9 @@ LL | let identity!(_) = 10;
88
| ^ no rules expected this token in macro call
99
|
1010
note: while trying to match meta-variable `$i:ident`
11-
--> $DIR/underscore-ident-matcher.rs:2:6
11+
--> $DIR/macro-fragment-ident-underscore-error.rs:5:6
1212
|
13-
LL | ($i: ident) => (
13+
LL | ($i: ident) => {
1414
| ^^^^^^^^^
1515

1616
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)