From 8aaf4ab59aacdc910ea132dbb13a67c8d69a1607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 13 Oct 2021 00:00:00 +0000 Subject: [PATCH] Deduplicate regions ids before merging them The merging code does not expect to see any duplicates. --- .../src/coherence/inherent_impls_overlap.rs | 1 + .../no-overlap.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs index 0373035a09a..beacf301cae 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs @@ -192,6 +192,7 @@ struct ConnectedRegion { .collect::>(); // Sort the id list so that the algorithm is deterministic ids.sort_unstable(); + ids.dedup(); let ids = ids; match &ids[..] { // Create a new connected region diff --git a/src/test/ui/inherent-impls-overlap-check/no-overlap.rs b/src/test/ui/inherent-impls-overlap-check/no-overlap.rs index 341bfc7b605..450e6d4202c 100644 --- a/src/test/ui/inherent-impls-overlap-check/no-overlap.rs +++ b/src/test/ui/inherent-impls-overlap-check/no-overlap.rs @@ -31,4 +31,23 @@ struct Foo {} impl Bar { fn foo() {} } impl Bar { fn foo() {} } +// Regression test for issue #89820: + +impl Bar { + pub fn a() {} + pub fn aa() {} +} + +impl Bar { + pub fn b() {} + pub fn bb() {} +} + +impl Bar { + pub fn a() {} + pub fn aa() {} + pub fn bb() {} + pub fn b() {} +} + fn main() {}