diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2021-03-06 21:06:01 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2021-03-06 21:19:31 +0300 |
| commit | 069e612e73f3fabb1184d9df009ea064118fffd8 (patch) | |
| tree | ac21d786ac7200ce5e26de78a10cc595b211aa68 /compiler/rustc_parse/src/parser/attr_wrapper.rs | |
| parent | 51748a8fc77283914d4135f31b5966a407208187 (diff) | |
| download | rust-069e612e73f3fabb1184d9df009ea064118fffd8.tar.gz rust-069e612e73f3fabb1184d9df009ea064118fffd8.zip | |
rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`
Diffstat (limited to 'compiler/rustc_parse/src/parser/attr_wrapper.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr_wrapper.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index f45d8d6c7a0..7512f46988c 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -72,6 +72,10 @@ impl<'a> Parser<'a> { let cursor_snapshot = self.token_cursor.clone(); let (mut ret, trailing_token) = f(self, attrs.attrs)?; + let tokens = match ret.tokens_mut() { + Some(tokens) if tokens.is_none() => tokens, + _ => return Ok(ret), + }; // Produces a `TokenStream` on-demand. Using `cursor_snapshot` // and `num_calls`, we can reconstruct the `TokenStream` seen @@ -128,14 +132,14 @@ impl<'a> Parser<'a> { } } - let lazy_impl = LazyTokenStreamImpl { + *tokens = Some(LazyTokenStream::new(LazyTokenStreamImpl { start_token, num_calls, cursor_snapshot, desugar_doc_comments: self.desugar_doc_comments, append_unglued_token: self.token_cursor.append_unglued_token.clone(), - }; - ret.finalize_tokens(LazyTokenStream::new(lazy_impl)); + })); + Ok(ret) } } |
