diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-07-22 08:48:29 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-07-22 08:57:31 -0700 |
| commit | d760aaf7077d0b4b1e093a3f353c4b84c2c6d394 (patch) | |
| tree | 241ae58d8905bf95c66ebcb08535c046ab07bbaa /src/libsyntax/tokenstream.rs | |
| parent | a57d5d7b25d471c902608223793d9b3bb8c4643c (diff) | |
| download | rust-d760aaf7077d0b4b1e093a3f353c4b84c2c6d394.tar.gz rust-d760aaf7077d0b4b1e093a3f353c4b84c2c6d394.zip | |
rustc: Implement tokenization of nested items
Ever plagued by #43081 the compiler can return surprising spans in situations related to procedural macros. This is exhibited by #47983 where whenever a procedural macro is invoked in a nested item context it would fail to have correct span information. While #43230 provided a "hack" to cache the token stream used for each item in the compiler it's not a full-blown solution. This commit continues to extend this "hack" a bit more to work for nested items. Previously in the parser the `parse_item` method would collect the tokens for an item into a cache on the item itself. It turned out, however, that nested items were parsed through the `parse_item_` method, so they didn't receive similar treatment. To remedy this situation the hook for collecting tokens was moved into `parse_item_` instead of `parse_item`. Afterwards the token collection scheme was updated to support nested collection of tokens. This is implemented by tracking `TokenStream` tokens instead of `TokenTree` to allow for collecting items into streams at intermediate layers and having them interleaved in the upper layers. All in all, this... Closes #47983
Diffstat (limited to 'src/libsyntax/tokenstream.rs')
| -rw-r--r-- | src/libsyntax/tokenstream.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 048a041f698..1a4236b280b 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -340,6 +340,7 @@ impl TokenStream { } } +#[derive(Clone)] pub struct TokenStreamBuilder(Vec<TokenStream>); impl TokenStreamBuilder { |
