Nicholas Nethercote
925f7fad57
Improve print_tts
by changing tokenstream::Spacing
.
...
`tokenstream::Spacing` appears on all `TokenTree::Token` instances,
both punct and non-punct. Its current usage:
- `Joint` means "can join with the next token *and* that token is a
punct".
- `Alone` means "cannot join with the next token *or* can join with the
next token but that token is not a punct".
The fact that `Alone` is used for two different cases is awkward.
This commit augments `tokenstream::Spacing` with a new variant
`JointHidden`, resulting in:
- `Joint` means "can join with the next token *and* that token is a
punct".
- `JointHidden` means "can join with the next token *and* that token is a
not a punct".
- `Alone` means "cannot join with the next token".
This *drastically* improves the output of `print_tts`. For example,
this:
```
stringify!(let a: Vec<u32> = vec![];)
```
currently produces this string:
```
let a : Vec < u32 > = vec! [] ;
```
With this PR, it now produces this string:
```
let a: Vec<u32> = vec![] ;
```
(The space after the `]` is because `TokenTree::Delimited` currently
doesn't have spacing information. The subsequent commit fixes this.)
The new `print_tts` doesn't replicate original code perfectly. E.g.
multiple space characters will be condensed into a single space
character. But it's much improved.
`print_tts` still produces the old, uglier output for code produced by
proc macros. Because we have to translate the generated code from
`proc_macro::Spacing` to the more expressive `token::Spacing`, which
results in too much `proc_macro::Along` usage and no
`proc_macro::JointHidden` usage. So `space_between` still exists and
is used by `print_tts` in conjunction with the `Spacing` field.
This change will also help with the removal of `Token::Interpolated`.
Currently interpolated tokens are pretty-printed nicely via AST pretty
printing. `Token::Interpolated` removal will mean they get printed with
`print_tts`. Without this change, that would result in much uglier
output for code produced by decl macro expansions. With this change, AST
pretty printing and `print_tts` produce similar results.
The commit also tweaks the comments on `proc_macro::Spacing`. In
particular, it refers to "compound tokens" rather than "multi-char
operators" because lifetimes aren't operators.
2023-12-11 09:19:09 +11:00
..
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-06-19 17:31:54 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-05-05 18:32:20 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-05-02 12:07:55 +00:00
2023-05-02 12:07:55 +00:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-21 22:01:50 +02:00
2023-03-30 08:46:31 -05:00
2023-04-02 17:54:24 -04:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-11-21 22:40:16 +01:00
2023-10-07 08:30:40 +02:00
2023-04-21 16:14:44 +00:00
2023-03-30 07:34:55 -05:00
2023-04-24 01:56:37 +02:00
2023-10-22 23:17:15 +11:00
2023-03-30 07:34:55 -05:00
2023-11-02 18:41:33 +11:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-05-17 23:54:21 -05:00
2023-05-02 12:07:55 +00:00
2023-05-17 11:39:11 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-06-17 17:20:02 -07:00
2023-06-17 17:20:02 -07:00
2023-10-17 17:31:47 +00:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-09-10 15:50:48 +00:00
2023-03-30 07:58:50 -05:00
2023-10-17 19:53:51 -04:00
2023-11-24 19:15:52 +01:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-07-19 14:10:07 +00:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-19 14:47:05 +00:00
2023-03-30 07:34:55 -05:00
2023-07-14 16:22:29 -04:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-10 19:19:38 -04:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-04-03 01:34:05 +00:00
2023-05-07 12:38:47 +01:00
2023-05-02 12:07:55 +00:00
2023-05-02 12:07:55 +00:00
2023-05-02 12:07:55 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-04-28 16:11:45 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-09-20 18:50:40 +02:00
2023-03-30 07:58:50 -05:00
2023-05-19 11:02:16 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-10-17 19:53:51 -04:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-04-25 00:08:35 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-04-25 00:08:35 +02:00
2023-05-23 07:37:16 +00:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-09-20 22:09:48 -07:00
2023-03-30 08:46:31 -05:00
2023-04-17 18:53:52 +02:00
2023-05-03 15:52:31 -07:00
2023-12-08 09:50:28 +08:00
2023-03-30 08:46:31 -05:00
2023-07-29 11:42:50 +02:00
2023-07-29 11:42:50 +02:00
2023-04-03 01:34:05 +00:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-21 22:01:50 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-09-10 15:50:48 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-09-11 22:01:55 +08:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-09-23 19:14:25 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-10-07 08:30:40 +02:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-19 14:47:05 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-05-11 14:47:56 +00:00
2023-07-18 22:15:47 +08:00
2023-12-02 04:40:12 +08:00
2023-12-04 22:28:00 +08:00
2023-07-19 14:47:05 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-07-02 13:41:36 +02:00
2023-08-18 09:41:08 +02:00
2023-03-30 07:34:55 -05:00
2023-09-10 15:50:48 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-11-24 19:15:52 +01:00
2023-08-18 13:51:42 +01:00
2023-03-30 07:58:50 -05:00
2023-11-30 08:26:13 -08:00
2023-11-30 08:26:13 -08:00
2023-11-30 08:26:13 -08:00
2023-03-30 08:46:31 -05:00
2023-09-08 00:28:40 +02:00
2023-08-30 13:45:57 +02:00
2023-08-30 13:45:57 +02:00
2023-08-30 13:45:57 +02:00
2023-03-30 07:34:55 -05:00
2023-08-30 13:45:57 +02:00
2023-08-30 13:45:57 +02:00
2023-08-30 13:45:57 +02:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-08-04 20:13:40 +02:00
2023-03-30 07:58:50 -05:00
2023-09-07 15:07:30 +02:00
2023-07-12 20:04:30 +02:00
2023-03-30 07:34:55 -05:00
2023-08-30 13:45:57 +02:00
2023-03-30 08:46:31 -05:00
2023-10-07 08:30:40 +02:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-04-18 11:01:07 -07:00
2023-10-07 08:30:40 +02:00
2023-10-07 08:30:40 +02:00
2023-10-07 08:30:40 +02:00
2023-10-07 08:30:40 +02:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-10-17 10:11:31 +02:00
2023-10-17 10:11:31 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-08-15 15:51:18 -05:00
2023-07-19 14:47:06 +00:00
2023-06-30 21:13:24 +00:00
2023-10-18 11:33:40 +00:00
2023-12-11 09:19:09 +11:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-06-16 20:56:01 -04:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-04-12 05:34:21 -05:00
2023-03-30 07:34:55 -05:00
2023-09-15 07:40:17 -07:00
2023-04-13 21:58:35 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-07-20 14:31:56 +02:00
2023-10-07 08:30:40 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-10-17 10:11:31 +02:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-04-03 10:23:08 +02:00
2023-05-02 12:07:55 +00:00
2023-03-30 07:34:55 -05:00
2023-04-27 18:22:06 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 08:46:31 -05:00
2023-06-16 20:56:01 -04:00
2023-03-30 07:34:55 -05:00
2023-06-23 17:22:07 +00:00
2023-03-30 07:34:55 -05:00
2023-05-02 12:07:55 +00:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-04-19 00:39:20 -05:00
2023-03-30 07:34:55 -05:00
2023-11-24 19:15:52 +01:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-11-30 17:28:29 +11:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-03-30 07:58:50 -05:00
2023-10-17 11:31:30 -04:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-07-01 20:24:15 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-10-09 11:42:23 +09:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:58:50 -05:00
2023-04-25 00:08:35 +02:00
2023-03-30 07:58:50 -05:00
2023-03-30 07:34:55 -05:00
2023-03-30 07:34:55 -05:00
2023-10-24 13:42:28 -07:00
2023-03-30 07:34:55 -05:00
2023-03-30 08:46:31 -05:00
2023-06-05 17:33:26 +02:00
2023-10-07 08:30:40 +02:00