diff options
| author | bors <bors@rust-lang.org> | 2021-01-15 05:36:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-15 05:36:48 +0000 |
| commit | dcf622eb70aebe16d40c5f88fa2a41fa7019541c (patch) | |
| tree | 0dc48e3ed0ac3cb88d7b86224b2248ae40b9add4 /compiler/rustc_parse/src/parser/item.rs | |
| parent | 3419da89aaaa678f680032fef9764e875aa06026 (diff) | |
| parent | a961e6785c7ed33a532bb6172ae0c95f44db5726 (diff) | |
| download | rust-dcf622eb70aebe16d40c5f88fa2a41fa7019541c.tar.gz rust-dcf622eb70aebe16d40c5f88fa2a41fa7019541c.zip | |
Auto merge of #80993 - Aaron1011:collect-set-tokens, r=petrochenkov
Set tokens on AST node in `collect_tokens` A new `HasTokens` trait is introduced, which is used to move logic from the callers of `collect_tokens` into the body of `collect_tokens`. In addition to reducing duplication, this paves the way for PR #80689, which needs to perform additional logic during token collection.
Diffstat (limited to 'compiler/rustc_parse/src/parser/item.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 4fcc9edb7d9..810ae61307c 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -125,19 +125,7 @@ impl<'a> Parser<'a> { item }; - let (mut item, tokens) = if needs_tokens { - let (item, tokens) = self.collect_tokens(parse_item)?; - (item, tokens) - } else { - (parse_item(self)?, None) - }; - if let Some(item) = &mut item { - // If we captured tokens during parsing (due to encountering an `NtItem`), - // use those instead - if item.tokens.is_none() { - item.tokens = tokens; - } - } + let item = if needs_tokens { self.collect_tokens(parse_item) } else { parse_item(self) }?; self.unclosed_delims.append(&mut unclosed_delims); Ok(item) |
