about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src/util.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-30 14:50:05 +0000
committerbors <bors@rust-lang.org>2022-07-30 14:50:05 +0000
commit1202bbaf48a0a919a2e0cfd8b7dce97e8fc3030d (patch)
tree66db6409f3f134b44bc1475829b0cdd371530a5c /compiler/rustc_monomorphize/src/util.rs
parentc907b6f7e0f89c3c4146b585961d2ddcf173584b (diff)
parent332dffb1f9964cdfcaa91853e4a65ccf6567138f (diff)
downloadrust-1202bbaf48a0a919a2e0cfd8b7dce97e8fc3030d.tar.gz
rust-1202bbaf48a0a919a2e0cfd8b7dce97e8fc3030d.zip
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`
Diffstat (limited to 'compiler/rustc_monomorphize/src/util.rs')
0 files changed, 0 insertions, 0 deletions