diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-04-11 14:37:07 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-04-11 14:55:33 +1000 |
| commit | 1eb53902f3b2b9c02b20472a8c7747b89bd54203 (patch) | |
| tree | 248d3b0e2d9cea2971e7fac850e19975d992d23f | |
| parent | 5716ae6982a4044429eb1d27d1921d70aebde64d (diff) | |
| download | rust-1eb53902f3b2b9c02b20472a8c7747b89bd54203.tar.gz rust-1eb53902f3b2b9c02b20472a8c7747b89bd54203.zip | |
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.
| -rw-r--r-- | compiler/rustc_borrowck/src/renumber.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs index 0fbf01dbe44..f37a7cce3b3 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, |
