diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-17 17:59:05 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-19 15:25:55 +1000 |
| commit | ca6649516f24fcfabeeee07e287d4de8958e83fe (patch) | |
| tree | f55dde27c1e973c93191615a996764c8dcfc8d70 /compiler/rustc_parse/src/parser/mod.rs | |
| parent | f9c7ca70cb3a10e0113113d054b9214b98455ae5 (diff) | |
| download | rust-ca6649516f24fcfabeeee07e287d4de8958e83fe.tar.gz rust-ca6649516f24fcfabeeee07e287d4de8958e83fe.zip | |
Make `Parser::num_bump_calls` 0-indexed.
Currently in `collect_tokens_trailing_token`, `start_pos` and `end_pos` are 1-indexed by `replace_ranges` is 0-indexed, which is really confusing. Making them both 0-indexed makes debugging much easier.
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 9a63a205242..33900503520 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -425,6 +425,11 @@ impl<'a> Parser<'a> { // Make parser point to the first token. parser.bump(); + // Change this from 1 back to 0 after the bump. This eases debugging of + // `Parser::collect_tokens_trailing_token` nicer because it makes the + // token positions 0-indexed which is nicer than 1-indexed. + parser.num_bump_calls = 0; + parser } |
