1
Fork 0

Fix bug in Parser::look_ahead.

The special case was failing to handle invisible delimiters on one path.

Fixes #128895.
This commit is contained in:
Nicholas Nethercote 2024-08-12 10:27:19 +10:00
parent fac7753802
commit 46b4c5adc5
3 changed files with 64 additions and 4 deletions

View file

@ -1166,10 +1166,12 @@ impl<'a> Parser<'a> {
match self.token_cursor.tree_cursor.look_ahead(0) {
Some(tree) => {
// Indexing stayed within the current token tree.
return match tree {
TokenTree::Token(token, _) => looker(token),
TokenTree::Delimited(dspan, _, delim, _) => {
looker(&Token::new(token::OpenDelim(*delim), dspan.open))
match tree {
TokenTree::Token(token, _) => return looker(token),
&TokenTree::Delimited(dspan, _, delim, _) => {
if delim != Delimiter::Invisible {
return looker(&Token::new(token::OpenDelim(delim), dspan.open));
}
}
};
}