parse_all_token_trees
cannot fail.
This commit is contained in:
parent
d12c6e947c
commit
d9f2fdfaed
@ -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.
|
/// 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<TokenTree>> {
|
pub fn parse_all_token_trees(&mut self) -> Vec<TokenTree> {
|
||||||
let mut tts = Vec::new();
|
let mut tts = Vec::new();
|
||||||
while self.token != token::Eof {
|
while self.token != token::Eof {
|
||||||
tts.push(self.parse_token_tree());
|
tts.push(self.parse_token_tree());
|
||||||
}
|
}
|
||||||
Ok(tts)
|
tts
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_tokens(&mut self) -> TokenStream {
|
pub fn parse_tokens(&mut self) -> TokenStream {
|
||||||
|
@ -76,13 +76,7 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Reparse a single token tree.
|
// Reparse a single token tree.
|
||||||
let mut reparsed_trees = match parser.parse_all_token_trees() {
|
let mut reparsed_trees = parser.parse_all_token_trees();
|
||||||
Ok(reparsed_trees) => reparsed_trees,
|
|
||||||
Err(diagnostic) => {
|
|
||||||
diagnostic.cancel();
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if reparsed_trees.len() != 1 {
|
if reparsed_trees.len() != 1 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user