From 1eb53902f3b2b9c02b20472a8c7747b89bd54203 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 11 Apr 2023 14:37:07 +1000 Subject: [PATCH] Fix `RegionCtxt::preference_value`. There's a bad pattern matching confusion present in this function. `_anon` gets assigned to, and then `_anon` is used as an unbound variable in the pattern, which is unrelated to the first `_anon`. If the `_anon` didn't start with `_` the compiler would give warnings. This was introduced in #104239. I have rewritten the function to remove the confusion and preserve the existing behaviour. This seems safest, because the original intent is not clear. --- compiler/rustc_borrowck/src/renumber.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs index 0fbf01dbe4455..f37a7cce3b3ec 100644 --- a/compiler/rustc_borrowck/src/renumber.rs +++ b/compiler/rustc_borrowck/src/renumber.rs @@ -69,12 +69,10 @@ impl RegionCtxt { /// Used to determine the representative of a component in the strongly connected /// constraint graph pub(crate) fn preference_value(self) -> usize { - let _anon = Symbol::intern("anon"); - match self { RegionCtxt::Unknown => 1, RegionCtxt::Existential(None) => 2, - RegionCtxt::Existential(Some(_anon)) | RegionCtxt::Free(_anon) => 2, + RegionCtxt::Existential(Some(_)) | RegionCtxt::Free(_) => 2, RegionCtxt::Location(_) => 3, RegionCtxt::TyContext(_) => 4, _ => 5,