Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New version of #1196 now that #1223 has changed token buffers to a flat layout, making the comparison trivial to implement.
As additional motivation and since it was first discovered in #1196, fixes #1235. The issue has nothing to do with
eq
comparing the scope pointer; in fact, the involved pointers actually have the same scope. Properly fixing the issue requires the ability to compare cursors in order to detect the case where the verbatim end is inside of aNone
-delimited group we previously would have stepped over.I removed the check for scope equality here, as it is much more useful to be able to be able to compare cursors which don't necessarily have the same scope end (e.g. to determine which of multiple speculative parses got the furthest). Additionally, we actually now rely on comparing two cursors at the same location with different scopes in
verbatim::between
treating them as equal, as we explicitly enter theNone
-delimited group which the end cursor implicitly entered.If exposing this is undesirable, we can reintroduce the scope check to
Cursor
comparison (treating cursors not with the same scope as unordered and nonequal) and introduce aCursor::position(&self) -> impl Ord
which can be used to order cursor's position ignoring the scope. (This would also provide a nice place to document how cursors are ordered.)I'm happy to implement + document that alternative approach if it's desired, but since just dropping the scope-matters in comparison is simpler, I'm providing this solution first.