Properly calculate best failure in macro matching
Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream. We now try to properly use the location in the token stream.
This commit is contained in:
parent
32da230588
commit
d72a0c437b
6 changed files with 80 additions and 15 deletions
|
@ -1503,6 +1503,10 @@ impl<'a> Parser<'a> {
|
|||
pub fn clear_expected_tokens(&mut self) {
|
||||
self.expected_tokens.clear();
|
||||
}
|
||||
|
||||
pub fn approx_token_stream_pos(&self) -> usize {
|
||||
self.token_cursor.num_next_calls
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn make_unclosed_delims_error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue