From 069e612e73f3fabb1184d9df009ea064118fffd8 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 6 Mar 2021 21:06:01 +0300 Subject: rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut` --- compiler/rustc_parse/src/parser/attr_wrapper.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_parse/src') 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) } } -- cgit 1.4.1-3-g733a5