]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errors
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 28 Dec 2022 21:22:19 +0000 (22:22 +0100)
committerGitHub <noreply@github.com>
Wed, 28 Dec 2022 21:22:19 +0000 (22:22 +0100)
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..

1  2 
compiler/rustc_expand/src/mbe/macro_rules.rs
compiler/rustc_parse/src/parser/mod.rs