From d9f2fdfaed8d18ede6d113426279c86d84d92445 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 31 Jul 2023 15:47:19 +1000 Subject: [PATCH] `parse_all_token_trees` cannot fail. --- compiler/rustc_parse/src/parser/mod.rs | 4 ++-- src/librustdoc/clean/render_macro_matchers.rs | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 57778d67098..b452eb6a401 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1288,12 +1288,12 @@ pub(crate) fn parse_token_tree(&mut self) -> TokenTree { } /// Parses a stream of tokens into a list of `TokenTree`s, up to EOF. - pub fn parse_all_token_trees(&mut self) -> PResult<'a, Vec> { + pub fn parse_all_token_trees(&mut self) -> Vec { let mut tts = Vec::new(); while self.token != token::Eof { tts.push(self.parse_token_tree()); } - Ok(tts) + tts } pub fn parse_tokens(&mut self) -> TokenStream { diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index ef38ca3c16c..b6120e814df 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -76,13 +76,7 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option reparsed_trees, - Err(diagnostic) => { - diagnostic.cancel(); - return None; - } - }; + let mut reparsed_trees = parser.parse_all_token_trees(); if reparsed_trees.len() != 1 { return None; }