diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-15 10:44:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-15 10:44:07 +0100 |
| commit | 1a6ed3050ff0ba96d0fa4e91fd657fe983623330 (patch) | |
| tree | 5baf5798ba2dd8131747634f09e8ff04dc01c4ec /src/test/ui/parser | |
| parent | ca92d90b5917e7176d5ff06607a2cd5352c088d3 (diff) | |
| parent | 7e7c11cf560527c4a7c70da63455cc23f4c51235 (diff) | |
| download | rust-1a6ed3050ff0ba96d0fa4e91fd657fe983623330.tar.gz rust-1a6ed3050ff0ba96d0fa4e91fd657fe983623330.zip | |
Rollup merge of #103439 - Nilstrieb:help-me-with-my-macro, r=estebank
Show note where the macro failed to match
When feeding the wrong tokens, it used to fail with a very generic error that wasn't very helpful. This change tries to help by noting where specifically the matching went wrong.
```rust
macro_rules! uwu {
(a a a b) => {};
}
uwu! { a a a c }
```
```diff
error: no rules expected the token `c`
--> macros.rs:5:14
|
1 | macro_rules! uwu {
| ---------------- when calling this macro
...
4 | uwu! { a a a c }
| ^ no rules expected this token in macro call
|
+note: while trying to match `b`
+ --> macros.rs:2:12
+ |
+2 | (a a a b) => {};
+ | ^
```
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/macro/macro-doc-comments-1.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/parser/macro/macro-doc-comments-2.stderr | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.stderr b/src/test/ui/parser/macro/macro-doc-comments-1.stderr index 0ebf3d52b63..eaeb62d2cfd 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-1.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-1.stderr @@ -9,6 +9,12 @@ LL | //! Inner | | | no rules expected this token in macro call | inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match + | +note: while trying to match `[` + --> $DIR/macro-doc-comments-1.rs:2:7 + | +LL | (#[$outer:meta]) => () + | ^ error: aborting due to previous error diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.stderr b/src/test/ui/parser/macro/macro-doc-comments-2.stderr index 346d865868d..1dcd95f6fad 100644 --- a/src/test/ui/parser/macro/macro-doc-comments-2.stderr +++ b/src/test/ui/parser/macro/macro-doc-comments-2.stderr @@ -9,6 +9,12 @@ LL | /// Outer | | | no rules expected this token in macro call | outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match + | +note: while trying to match `!` + --> $DIR/macro-doc-comments-2.rs:2:7 + | +LL | (#![$inner:meta]) => () + | ^ error: aborting due to previous error |
