]> git.lizzy.rs Git - rust.git/commit
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)
commitc52d58f346aea2e2e7ed650ee95785d33500a6d0
tree4220254f810af0804181959838ff4eb500f68af0
parent0b7ed65c13064ff1afe334bb781c02d172f54a48
parentd72a0c437bd2db922b954af7b0278e1f4bf31edf
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..
compiler/rustc_expand/src/mbe/macro_rules.rs
compiler/rustc_parse/src/parser/mod.rs