rust/compiler/rustc_parse/src/parser
Nicholas Nethercote ebe1305b1e Remove the bogus special case from Parser::look_ahead.
The general case at the bottom of `look_ahead` is slow, because it
clones the token cursor. Above it there is a special case for
performance that is hit most of the time and avoids the cloning.
Unfortunately, its behaviour differs from the general case in two ways.

- When within a pair of delimiters, if you look any distance past the
  closing delimiter you get the closing delimiter instead of what comes
  after the closing delimiter.

- It uses `tree_cursor.look_ahead(dist - 1)` which totally confuses
  tokens with token trees. This means that only the first token in a
  token tree will be seen. E.g. in a sequence like `{ a }` the `a` and
  `}` will be skipped over. Bad!

It's likely that these differences weren't noticed before now because
the use of `look_ahead` in the parser is limited to small distances and
relatively few contexts.

Removing the special case causes slowdowns up of to 2% on a range of
benchmarks. The next commit will add a new, correct special case to
regain that lost performance.
2024-07-12 13:33:38 +10:00
..
mut_visit Specialize assert_pred. 2024-06-06 08:26:54 +10:00
tokenstream Move some tests from rustc_expand to rustc_parse. 2024-05-06 09:06:02 +10:00
attr.rs Simplify ReplaceRange. 2024-07-07 15:58:36 +10:00
attr_wrapper.rs Remove Clone derive from LazyAttrTokenStreamImpl. 2024-07-07 16:24:51 +10:00
diagnostics.rs Rollup merge of #126125 - dev-ardi:conflict-markers, r=estebank 2024-06-21 09:12:34 +02:00
expr.rs Rollup merge of #127103 - compiler-errors:tighten-trait-bound-parsing, r=fmease 2024-06-29 09:14:59 +02:00
generics.rs Move binder and polarity parsing into parse_generic_ty_bound 2024-06-28 19:40:31 -04:00
item.rs StaticForeignItem and StaticItem are the same 2024-06-20 19:51:09 -04:00
mod.rs Remove the bogus special case from Parser::look_ahead. 2024-07-12 13:33:38 +10:00
nonterminal.rs Rework pattern and expression nonterminal kinds. 2024-06-23 15:57:24 +10:00
pat.rs Inline can_begin_literal_maybe_minus call into two places. 2024-06-20 04:50:38 +10:00
path.rs Change RTN to use .. again 2024-06-28 14:20:43 -04:00
stmt.rs Refactor parse_expr_res. 2024-06-19 19:12:02 +10:00
tests.rs Remove the bogus special case from Parser::look_ahead. 2024-07-12 13:33:38 +10:00
ty.rs Move binder and polarity parsing into parse_generic_ty_bound 2024-06-28 19:40:31 -04:00