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.
This commit is contained in:
@@ -20,7 +20,7 @@ use rustc_data_structures::map_in_place::MapInPlace;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{struct_span_err, Applicability, PResult};
|
||||
use rustc_feature::Features;
|
||||
use rustc_parse::parser::{AttemptLocalParseRecovery, Parser};
|
||||
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, Parser};
|
||||
use rustc_parse::validate_attr;
|
||||
use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
|
||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||
@@ -913,7 +913,7 @@ pub fn parse_ast_fragment<'a>(
|
||||
Ok(match kind {
|
||||
AstFragmentKind::Items => {
|
||||
let mut items = SmallVec::new();
|
||||
while let Some(item) = this.parse_item()? {
|
||||
while let Some(item) = this.parse_item(ForceCollect::No)? {
|
||||
items.push(item);
|
||||
}
|
||||
AstFragment::Items(items)
|
||||
|
||||
Reference in New Issue
Block a user