diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-01-18 16:47:37 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2021-01-20 18:09:32 -0500 |
| commit | 11b1e370161dd09c095350c66f7b187fc9654ec6 (patch) | |
| tree | c46df174a600d0557fe310f927cdabfec2ef06fc /compiler/rustc_builtin_macros/src/source_util.rs | |
| parent | a4cbb44ae2c80545db957763b502dc7f6ea22085 (diff) | |
| download | rust-11b1e370161dd09c095350c66f7b187fc9654ec6.tar.gz rust-11b1e370161dd09c095350c66f7b187fc9654ec6.zip | |
Force token collection to run when parsing nonterminals
Fixes #81007 Previously, we would fail to collect tokens in the proper place when only builtin attributes were present. As a result, we would end up with attribute tokens in the collected `TokenStream`, leading to duplication when we attempted to prepend the attributes from the AST node. We now explicitly track when token collection must be performed due to nomterminal parsing.
Diffstat (limited to 'compiler/rustc_builtin_macros/src/source_util.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/source_util.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index f76bbd83819..28efd483c86 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -5,7 +5,8 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast_pretty::pprust; use rustc_expand::base::{self, *}; use rustc_expand::module::DirectoryOwnership; -use rustc_parse::{self, new_parser_from_file, parser::Parser}; +use rustc_parse::parser::{ForceCollect, Parser}; +use rustc_parse::{self, new_parser_from_file}; use rustc_session::lint::builtin::INCOMPLETE_INCLUDE; use rustc_span::symbol::Symbol; use rustc_span::{self, Pos, Span}; @@ -139,7 +140,7 @@ pub fn expand_include<'cx>( fn make_items(mut self: Box<ExpandResult<'a>>) -> Option<SmallVec<[P<ast::Item>; 1]>> { let mut ret = SmallVec::new(); while self.p.token != token::Eof { - match self.p.parse_item() { + match self.p.parse_item(ForceCollect::No) { Err(mut err) => { err.emit(); break; |
