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:
parent
a4cbb44ae2
commit
11b1e37016
13 changed files with 233 additions and 72 deletions
|
@ -9,6 +9,7 @@ use rustc_data_structures::sync::Lrc;
|
|||
use rustc_errors::{struct_span_err, Applicability, ErrorReported};
|
||||
use rustc_lexer::is_ident;
|
||||
use rustc_parse::nt_to_tokenstream;
|
||||
use rustc_parse::parser::ForceCollect;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
||||
|
@ -117,7 +118,7 @@ impl MultiItemModifier for ProcMacroDerive {
|
|||
let mut items = vec![];
|
||||
|
||||
loop {
|
||||
match parser.parse_item() {
|
||||
match parser.parse_item(ForceCollect::No) {
|
||||
Ok(None) => break,
|
||||
Ok(Some(item)) => {
|
||||
if is_stmt {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue