From 2be935d396a650a1480859a75011a742df882c74 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 18 Jan 2021 16:47:37 -0500 Subject: [PATCH] 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. --- clippy_lints/src/doc.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index f518da55cd7..3a754f49917 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -12,6 +12,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_parse::maybe_new_parser_from_source_str; +use rustc_parse::parser::ForceCollect; use rustc_session::parse::ParseSess; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::edition::Edition; @@ -483,7 +484,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { let mut relevant_main_found = false; loop { - match parser.parse_item() { + match parser.parse_item(ForceCollect::No) { Ok(Some(item)) => match &item.kind { // Tests with one of these items are ignored ItemKind::Static(..)