rust/compiler/rustc_ast_lowering/src
Nicholas Nethercote 99f5945f85 Overhaul MacArgs::Eq.
The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.
2022-05-05 07:06:12 +10:00
..
asm.rs Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
block.rs Add more information to impl Trait deny error 2022-02-17 18:45:53 -08:00
expr.rs Use LifetimeRes during lowering. 2022-04-27 22:00:15 +02:00
index.rs Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov 2022-04-27 23:13:28 +00:00
item.rs Auto merge of #91557 - cjgillot:ast-lifetimes-named, r=petrochenkov 2022-04-27 23:13:28 +00:00
lib.rs Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
pat.rs Add more information to impl Trait deny error 2022-02-17 18:45:53 -08:00
path.rs Create a specific struct for lifetime capture. 2022-04-27 22:03:12 +02:00