rust/compiler/rustc_ast/src
bors 2831701757 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)
```
2023-11-17 20:57:12 +00:00
..
attr More detail when expecting expression but encountering bad macro argument 2023-11-16 16:19:04 +00:00
expand Generate better function argument names in global_allocator expansion 2023-08-06 07:36:05 -07:00
util Add gen blocks to ast and do some broken ast lowering 2023-10-27 13:05:48 +00:00
ast_traits.rs Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
ast.rs feat(hir): Store the Span of the move keyword 2023-11-04 19:39:32 +01:00
entry.rs Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
format.rs get auto traits for parallel rustc 2023-08-02 16:21:45 +08:00
lib.rs Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
mut_visit.rs More detail when expecting expression but encountering bad macro argument 2023-11-16 16:19:04 +00:00
node_id.rs Various minor Idx-related tweaks 2023-04-16 02:42:50 -07:00
ptr.rs make rustc compilable 2023-04-16 07:25:13 +00:00
token.rs Auto merge of #114292 - estebank:issue-71039, r=b-naber 2023-11-17 20:57:12 +00:00
tokenstream.rs More detail when expecting expression but encountering bad macro argument 2023-11-16 16:19:04 +00:00
visit.rs fixes for rustfmt + ast visitor 2023-11-04 20:39:15 +01:00