Skip to content

Commit

Permalink
Fix bug in Parser::look_ahead.
Browse files Browse the repository at this point in the history
The special case was failing to handle invisible delimiters on one path.

Fixes rust-lang#128895.
  • Loading branch information
nnethercote committed Aug 12, 2024
1 parent fac7753 commit 4920cb9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
};
}
Expand Down

0 comments on commit 4920cb9

Please sign in to comment.