rust/compiler/rustc_expand/src
bors 1202bbaf48 Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov
Remove `TreeAndSpacing`.

A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.

r? `@petrochenkov`
2022-07-30 14:50:05 +00:00
..
mbe Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
mut_visit
parse Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
tokenstream Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
base.rs rustc_expand: Switch FxHashMap to FxIndexMap where iteration is used 2022-07-16 13:23:05 +02:00
build.rs Parse closure binders 2022-07-12 16:25:16 +04:00
config.rs Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov 2022-07-30 14:50:05 +00:00
expand.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
lib.rs Auto merge of #99320 - NiklasJonsson:84447/rustc_expand, r=compiler-errors 2022-07-23 07:59:54 +00:00
mbe.rs
module.rs avoid some Symbol to String conversions 2022-07-17 04:09:20 +09:00
placeholders.rs
proc_macro_server.rs Remove TreeAndSpacing. 2022-07-29 15:52:15 +10:00
proc_macro.rs Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov 2022-07-30 14:50:05 +00:00
tests.rs avoid many &str to String conversions with MultiSpan::push_span_label 2022-06-29 21:16:43 +09:00