diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-12-28 22:22:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-28 22:22:19 +0100 |
| commit | c52d58f346aea2e2e7ed650ee95785d33500a6d0 (patch) | |
| tree | 4220254f810af0804181959838ff4eb500f68af0 /compiler/rustc_parse/src | |
| parent | 0b7ed65c13064ff1afe334bb781c02d172f54a48 (diff) | |
| parent | d72a0c437bd2db922b954af7b0278e1f4bf31edf (diff) | |
| download | rust-c52d58f346aea2e2e7ed650ee95785d33500a6d0.tar.gz rust-c52d58f346aea2e2e7ed650ee95785d33500a6d0.zip | |
Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errors
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 needs a little cleanup as the `best_failure` field is getting out of hand but it should be mostly good to go. I hope I didn't violate too many abstraction boundaries..
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 40b88788caa..919e71bd115 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1499,6 +1499,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( |
