Skip to content

Commit

Permalink
Force token collection to run when parsing nonterminals
Browse files Browse the repository at this point in the history
Fixes rust-lang#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.
  • Loading branch information
Aaron1011 committed Jan 20, 2021
1 parent 9009f8f commit 2be935d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(..)
Expand Down

0 comments on commit 2be935d

Please sign in to comment.