Skip to content

Commit 4920cb9

Browse files
committed
Fix bug in Parser::look_ahead.
The special case was failing to handle invisible delimiters on one path. Fixes rust-lang#128895.
1 parent fac7753 commit 4920cb9

File tree

1 file changed

+6
-4
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+6
-4
lines changed

compiler/rustc_parse/src/parser/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,12 @@ impl<'a> Parser<'a> {
11661166
match self.token_cursor.tree_cursor.look_ahead(0) {
11671167
Some(tree) => {
11681168
// Indexing stayed within the current token tree.
1169-
return match tree {
1170-
TokenTree::Token(token, _) => looker(token),
1171-
TokenTree::Delimited(dspan, _, delim, _) => {
1172-
looker(&Token::new(token::OpenDelim(*delim), dspan.open))
1169+
match tree {
1170+
TokenTree::Token(token, _) => return looker(token),
1171+
&TokenTree::Delimited(dspan, _, delim, _) => {
1172+
if delim != Delimiter::Invisible {
1173+
return looker(&Token::new(token::OpenDelim(delim), dspan.open));
1174+
}
11731175
}
11741176
};
11751177
}

0 commit comments

Comments
 (0)