about summary refs log tree commit diff
path: root/compiler/rustc_index/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-17 20:57:12 +0000
committerbors <bors@rust-lang.org>2023-11-17 20:57:12 +0000
commit2831701757eb7b3105eda26a306c2f3a97e2664b (patch)
tree578877e9b318c070b1b4880e12d302250044ac57 /compiler/rustc_index/src
parentf6dcaee23f274dd18b391b2f0f70df6e98f1c3b2 (diff)
parent4e418805da5867bc48d82ba1cc7eff2ba68be575 (diff)
downloadrust-2831701757eb7b3105eda26a306c2f3a97e2664b.tar.gz
rust-2831701757eb7b3105eda26a306c2f3a97e2664b.zip
Auto merge of #114292 - estebank:issue-71039, r=b-naber
More detail when expecting expression but encountering bad macro argument

On nested macro invocations where the same macro fragment changes fragment type from one to the next, point at the chain of invocations and at the macro fragment definition place, explaining that the change has occurred.

Fix #71039.

```
error: expected expression, found pattern `1 + 1`
  --> $DIR/trace_faulty_macros.rs:49:37
   |
LL |     (let $p:pat = $e:expr) => {test!(($p,$e))};
   |                   -------                -- this is interpreted as expression, but it is expected to be pattern
   |                   |
   |                   this macro fragment matcher is expression
...
LL |     (($p:pat, $e:pat)) => {let $p = $e;};
   |               ------                ^^ expected expression
   |               |
   |               this macro fragment matcher is pattern
...
LL |     test!(let x = 1+1);
   |     ------------------
   |     |             |
   |     |             this is expected to be expression
   |     in this macro invocation
   |
   = note: when forwarding a matched fragment to another macro-by-example, matchers in the second macro will see an opaque AST of the fragment type, not the underlying tokens
   = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
```
Diffstat (limited to 'compiler/rustc_index/src')
0 files changed, 0 insertions, 0 deletions